|
On Dec 29, 4:40 pm, STran <st.t...@gmail.com> wrote:
> Hi,
> I have a dataset full of coded variables. I would like to create a new
> dataset from the original, pulling out only variables that contain a
> specific string of characters in them. In this case, the specific
> string of characters is at the end of the variable name.
>
> data_have variables:
> c1fpop1
> c2fpop2
> c3fpop3
> ...
> c1mpop1
> c2mpop2
> c3mpop3
> ...
>
> data_want variables (all those containing "fpop"):
> c1fpop1
> c2fpop2
> c3fpop3
> ...
>
> Thanks for your help.
> Sarah
Untested:
proc sql noprint;
select name into :nameList separated by ' '
from dictionary.columns
where upcase(memname) = 'DATA_HAVE' & index(upcase(name), 'FPOP') > 0
;
create table data_want as
select &nameList.
from data_have
;
quit;
|