07-04-2016 04:27 AM
I have a big data set with more than 4000 columns and need to keep columns that have specific sequence of characters in their name (e.g. "_US_"). Can I that using wildcards in "Keep" statement?
07-04-2016 04:36 AM
07-04-2016 05:16 AM
If the sequence is in the middle of the character name you can select those variable in a macro statement separated by space and
use this macro variable in a keep statement.
For doing this operation you shall use the dictionary table - vcolumn:
proc sql; select name into :vr separated by ' ' from sashelp.vcolumn where libname eq 'SASHELP' and memname eq 'CLASS' and name like '%h%'; quit; data want; set sashelp.class; keep &vr; run;
07-04-2016 05:31 AM
On a similar pattern as per @Loko suggestion:
proc contents data=have out=vars(keep=name);
select name into :vars_needed separated by ' '
07-04-2016 09:27 AM
I really thank all of you for you replies,
The solution using proc sql worked fine,
(I was just wondering if a more ''complex'' KEEP statement could do the job but it seems there is no such possibility)
07-04-2016 10:29 AM