plz find & remove the
You have not provided a dataset in the parameter to the macro call:
%check(dsName=);
^
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
%end;
%else %do;
%put Dataset &dsname. does not exist;
%end;
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.
Here, in my post, where the upward point triangle is, you need to put a dataset (with library if not work);
%check(dsName=);
^
E.g.
%check(dsName=sashelp.class);
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.
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.
E.g.
%check(dsName=sashelp.class);
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.
Hi @RTelang,
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).
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.