<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Underscore in variable names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Underscore-in-variable-names/m-p/57894#M12571</link>
    <description>I can think of two ways to avoid this.&lt;BR /&gt;
&lt;BR /&gt;
1) Don't put spaces in front of variable names in Excel&lt;BR /&gt;
2) Write a macro to remove underscores if they are the first character of a variable name.</description>
    <pubDate>Tue, 16 Feb 2010 16:42:27 GMT</pubDate>
    <dc:creator>Paige</dc:creator>
    <dc:date>2010-02-16T16:42:27Z</dc:date>
    <item>
      <title>Underscore in variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Underscore-in-variable-names/m-p/57893#M12570</link>
      <description>Hi,&lt;BR /&gt;
  Sometimes the variables given in excel come with spaces in front of them.SAS reads them with an underscore followed by the variable name.How to avoid this?&lt;BR /&gt;
&lt;BR /&gt;
for instance, NDC is the field name.when we recieve the data in excel,there will be space in front of NDC so SAS reads it as _NDC.</description>
      <pubDate>Tue, 16 Feb 2010 15:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Underscore-in-variable-names/m-p/57893#M12570</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-02-16T15:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Underscore in variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Underscore-in-variable-names/m-p/57894#M12571</link>
      <description>I can think of two ways to avoid this.&lt;BR /&gt;
&lt;BR /&gt;
1) Don't put spaces in front of variable names in Excel&lt;BR /&gt;
2) Write a macro to remove underscores if they are the first character of a variable name.</description>
      <pubDate>Tue, 16 Feb 2010 16:42:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Underscore-in-variable-names/m-p/57894#M12571</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-02-16T16:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Underscore in variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Underscore-in-variable-names/m-p/57895#M12572</link>
      <description>I'm sharing the code with you all:&lt;BR /&gt;
data abc(keep=name column2 column3);&lt;BR /&gt;
   set sashelp.vcolumn;&lt;BR /&gt;
   where libname='WORK' and memname='FAIRVIEW_FIN';&lt;BR /&gt;
   if  substr(name,1,1) = '_'  then  column2 = substr(name, 2, length(name));&lt;BR /&gt;
   else column2=name;&lt;BR /&gt;
   column3=left(trim(name))||'='||column2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql; &lt;BR /&gt;
  select distinct column3 into: new_column seperated by ' '&lt;BR /&gt;
  from abc;&lt;BR /&gt;
quit;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data Fairview_fin (rename = (&amp;amp;new_column));&lt;BR /&gt;
   set Fairview_fin;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 16 Feb 2010 21:23:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Underscore-in-variable-names/m-p/57895#M12572</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-02-16T21:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Underscore in variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Underscore-in-variable-names/m-p/57896#M12573</link>
      <description>You can use the SAS option "validvarname=any".&lt;BR /&gt;
If "any" is set then the Excel variable names won't be converted to comply with SAS naming conventions during import.&lt;BR /&gt;
&lt;BR /&gt;
You can do it - but I wouldn't as it will cause you quite a bit of pain. Variables with non-conforming names must be addresses as literals meaning that whenever you use the variable you have to quote the name in the form: '&lt;VARIABLE name=""&gt;'n&lt;BR /&gt;
&lt;BR /&gt;
For SAS EG 4.2&lt;BR /&gt;
In step 2 of the import wizard there is a checkbox "rename columns to comply with SAS naming conventions". Make sure that this checkbox is not ticked if you want to avoid the conversion.&lt;BR /&gt;
Again: I recommend to choose conversion. You still keep the excel source variable names as SAS variable labels.&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick&lt;/VARIABLE&gt;</description>
      <pubDate>Wed, 17 Feb 2010 10:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Underscore-in-variable-names/m-p/57896#M12573</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-02-17T10:40:57Z</dc:date>
    </item>
  </channel>
</rss>

