Works perfectly, thanks for your help!
I would also suggest using DICTIONARY.COLUMNS in stead of SASHELP.VCOLUMN in Proc SQL. I notice very different performance, seconds versus minutes, with the number of libraries, datasets and variables involved on my system.
Since the OP says that his datasets have "hundreds of variables" this performance might be noticeable.
I also have the experience that @Reeza commented on. With time, SAS seems to have gotten much better at handing over where conditions through the SASHELP.Vxxxxxx views.
In earlier times, I would have the same problems with very bad performance of SASHELP:VTABLE or SASHELP.VCOLUMNS, but now (9.4 M5) there's no noticeable difference.
Hello,
%macro freq_means(lib, mem, var);
data _NULL_;
set &lib..&mem.;
if vtype(&var.)="C" then call execute('proc freq data=&lib..&mem.; table &var.; run;');
else call execute('proc means data=&lib..&mem.; var &var.; run;');
stop;
run;
%mend;
%freq_means(sashelp, class, NAME);
%freq_means(sashelp, class, age);
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.