BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ian_Tfirn
Calcite | Level 5

Works perfectly, thanks for your help!

Reeza
Super User
@heffo, use the TRIMMED option in PROC SQL to avoid the need to get rid of extra spaces issue. You should also remove the quotes from the text comparison.
ballardw
Super User

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.

Reeza
Super User
The difference matters with the number of data sets and libraries, not columns. If that was the case I'd switch to use PROC CONTENTS or FUNCTIONS. The difference between dictionary and sashelp doesn't exist anymore the last time I tested it.
Kurt_Bremser
Super User

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.

heffo
Pyrite | Level 9
At one time or another I had some problems with missing values and quotes. So, I started to use the quotes to help this. I don't know if this is the best way to do it.
It might have been when having x ne &y or similar and not the = .
gamotte
Rhodochrosite | Level 12

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);

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 21 replies
  • 3443 views
  • 6 likes
  • 6 in conversation