11-25-2015 04:45 AM
plz find & remove the
11-25-2015 05:19 AM
You have not provided a dataset in the parameter to the macro call:
This is invalid as open needs a valid dataset. As you have gone ahead with this solution, you will need to include further code at the beginning of the macro to ensure that the dataset is valid and exists, i.e.
%if %sysfunc(exists(&dsname.)) %then %do;
your macro code
%put Dataset &dsname. does not exist;
Or, your could just not use macro code at all and go with:
proc sql noprint; select NOBS into NUMOBS from DICTIONARY.TABLES where LIBNAME="SASHELP" and MEMNAME="CLASS"; quit;
As there is almost never a "need" to do things in macro language.
11-25-2015 05:34 AM
11-25-2015 05:39 AM
11-25-2015 05:42 AM
In your library WORK, there is no dataset called DATA1. This is what the log message is telling you. The macro will only work on a dataset which exists in the library given. So open SAS, find a dataset, if there is nothing in your WORK library, then look at SASHELP. Take the CLASS dataset as an example from there and replace work.data1 in your example with sashelp.class.
11-26-2015 08:04 AM - edited 11-26-2015 08:05 AM
If you need a macro that gives you the number of rows in a table, the minimum input to this macro needs to be the name of a specific table for which you want the number of rows.
You suggest a solution where you would like to to supply "dsName=100". What kind of input is the value 100? How will this input be used to give you the number of rows in a table?
Perhaps you are not yet familiar with macro functionality and how to call a macro? Then I suggest some reading. E.g.
11-25-2015 08:11 AM - edited 11-25-2015 08:18 AM
If you just "need a macro to display number of observations in a dataset" (as you say) or a macro for some other day-to-day task, you can resort to existing macros on the web. Why reinvent the wheel? For example, have a look at Roland's SAS® Macros. This website also contains many tips and tricks for writing your own macros from the author of this large macro collection, Roland Rashleigh-Berry (a former colleague of mine).