title: SAS List of variables containing special characters
body: <p>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.</p>
  
  <p>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 &amp;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.</p>
  
  <p>Any insights or directions would be appreciated. Here is the code I tried so far:</p>
  
  <p>1) Importing:</p>
  
  <pre><code>proc import datafile='file_oldname.csv'
   dbms=csv
   out= oldName
   replace;
   delimiter=',';
   getnames=yes;  
  run;
  </code></pre>
  
  <p>2) Making my list of oldNames;
  * A macro variable contanining the oldvariables names;
  * Using Proc Contents and Proc SQL;</p>
  
  <pre><code>proc contents data=oldName out=listOldName;
  run;
  
  options VALIDMEMNAME=EXTEND;
  proc sql noprint;
  select distinct(name) into:vars separated by " " from listOldName;
  quit;
  
  %put &amp;vars;
  </code></pre>
  
  <p>&amp;vars contains the list of variables, however if I try to use it, it fails because of the special characters.</p>
  
  <p>How can I wrap the &amp;vars properly so that the variable names with special characters can be used? I want to further renamed them by new names.</p>
  
  <p>Thanks a lot! </p>