I have around 20 files in a library. I want to apply Proc means to all the files in the library using a macro than writing all 20 file names.
It should take all the file names automatically if I specify the library name.
You can get all the dataset names in a library from sashelp.vtable and call execute should be straightforward. You also don't necessarily need a macro depending on your needs. Here's a demo - untested.
%let lname=WORK; data dnames; set sashelp.vtable; where libname=upper("&lname"); run; data _null_; set dnames; str=cats("proc means data=&lname..", memname, "; run;"); call execute(str); run;
The code is working.
I was actually looking to know about missing values in each dataset using proc means, NMISS option.
As cats function is removing the trailing and leading blanks I am unable to give the NMISS option.
Could you please look into it.
str=cats("proc means data=&library..", memname, "nmiss", "; run;");
It is generating the statements
proc means data=TASK3.DEMOSSUBMITnmiss; run;
ERROR: File TASK3.DEMOSSUBMITNMISS.DATA does not exist.
where Nmiss is mixing up with the dataset name.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.