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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 749 views
  • 2 likes
  • 3 in conversation