Escolar Documentos
Profissional Documentos
Cultura Documentos
Well...there are many ways of getting the observation count into a macro variable...but there a few pros and cons in those
methods...
2. datastep
eg.
data new;
set old nobs=num;
call symputx('macvar',num);
run;
where the values of memname, memtype and libname represents ur dataset name, data type and libname the library
where the dataset is located...
NOTE: the values of memname, memtype and libname should be in capital letters mandatorily...
4. use attrn() function with nlobs option to get the obs count...used in the macro example below....
Here's a SAS macro that counts the Observations in a dataset passed as a parameter and stores the value in a macro
variable named macrovar....
%macro RecsInDS(table,macvar);
%global &macvar;
%let &macvar = %sysfunc(attrn(&handle, nlobs)); /* get the observation count into the macvar
macro variable using the function attrn() with nlobs as the option*/
%end;
%PUT RecsInDS &table: &&&macvar. &macvar=&&&macvar.; /* write the Record count to the Log */
%mend RecsInDS;
%RecsInDS(sashelp.air,obs);