I am a novice for SAS programming and I am trying to create a list of old_variable names so I can work with them (subset, rename, spaces, etc.), however the variable names have funky characters (#, parenthesis, single quotes, numbers, you name it). Each variable is delimited-separated by ';' and the source file is in csv format. I need to do it for 44 different files and each file has about 199 variables.
So far, I have tried a macro where I create a list of the variables, however, the code fails when I try to use the macro &vars because of the special characters. I have checked SAS paper 005-2013, however I believe I am not really sure how to use the functions in my code.
Any insights or directions would be appreciated. Here is the code I tried so far:
1) Importing:
proc import datafile='file_oldname.csv'
dbms=csv
out= oldName
replace;
delimiter=',';
getnames=yes;
run;
2) Making my list of oldNames; * A macro variable contanining the oldvariables names; * Using Proc Contents and Proc SQL;
proc contents data=oldName out=listOldName;
run;
options VALIDMEMNAME=EXTEND;
proc sql noprint;
select distinct(name) into:vars separated by " " from listOldName;
quit;
%put &vars;
&vars contains the list of variables, however if I try to use it, it fails because of the special characters.
How can I wrap the &vars properly so that the variable names with special characters can be used? I want to further renamed them by new names.
Thanks a lot!