BookmarkSubscribeRSS Feed
Emma_at_SAS
Lapis Lazuli | Level 10

In my dataset, I want to create three subsets of variables with the suffix [x] [y] [z]. 

If these were prefix, I knew how to do it in a data set and using (keep=prefix:). Is there an easy way for suffix?

Thanks

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Not as easy as the : operator for the prefix. 

 

However, it can be done. A Google search will probably give you a few ways quickly.

sbxkoenk
SAS Super FREQ

Hello,

 

Unfortunately there's no easy way with a wildcard.

 

You can do this (to be adapted and applied to your situation):

proc sql noprint;
 select distinct name into: names separated by ' '
 from dictionary.columns 
 where     libname='SASHELP' 
       and memname='CLASS'
       and upcase(name) like '%HT';
quit;
%PUT &=names;

data want;
 set sashelp.class(drop=&names);
run;
/* end of program */

Cheers,

Koen

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
  • 2 replies
  • 1500 views
  • 2 likes
  • 3 in conversation