%macro obsnvars(ds); %global dset nvars nobs; %let dset=&ds; %let dsid = %sysfunc(open(&dset)); %if &dsid %then %do; %let nobs =%sysfunc(attrn(&dsid,NOBS)); %let nvars=%sysfunc(attrn(&dsid,NVARS)); %let rc = %sysfunc(close(&dsid)); %put &dset has &nvars variable(s) and &nobs observation(s).; %end; %else %put Open for data set &dset failed - %sysfunc(sysmsg()); %mend obsnvars; %obsnvars(sasuser.houses)
******************************************************************************;
%macro nobs(Dsn= /*Data set name */); if exist("&Dsn") then do; Dsid = open("&Dsn","i"); Nobs = attrn(Dsid,"Nlobs"); end; else Nobs=.; rc = close(Dsid); %mend nobs;
No comments:
Post a Comment