<?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: convert column names to numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348638#M273421</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32246"&gt;@ChrisBrooks&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;...&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;you'll have to use it in every piece of code which references this file&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;And that's why I've proposed to use labels and didn't even mention SAS name literals for variable names (they are to be avoided).&lt;/P&gt;</description>
    <pubDate>Mon, 10 Apr 2017 10:32:02 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2017-04-10T10:32:02Z</dc:date>
    <item>
      <title>convert column names to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348497#M273417</link>
      <description>&lt;P&gt;Good day! here is my data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data samp1;&lt;BR /&gt;input treeno nob b1-b3;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 10 11 12&lt;/P&gt;&lt;P&gt;2 13 14 15&lt;/P&gt;&lt;P&gt;3 16 17 18&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it prints as&lt;/P&gt;&lt;P&gt;treeno b1 b2 b3&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10 11 12&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13 14 15&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16 17 18&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what i would want to do is replace b1 to b3 as just numbers 1 to 3. could you pls help me? thanks&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 11:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348497#M273417</guid>
      <dc:creator>cdvdc</dc:creator>
      <dc:date>2017-04-09T11:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: convert column names to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348504#M273418</link>
      <description>&lt;P&gt;SAS variables must follow naming rules and one of these&amp;nbsp;rules states&amp;nbsp;that a SAS variable name must start with an underscore or letter.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can assign labels to variables for printing. See below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample1;
  input treeno b1-b3;
  label b1='1' b2='2' b3='3';
cards;
1 10 11 12
2 13 14 15
3 16 17 18
;
run;

proc print data=sample1 noobs label;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8234i06DC18440D517459/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 11:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348504#M273418</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-04-09T11:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: convert column names to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348513#M273419</link>
      <description>&lt;P&gt;You prolly need to use &lt;STRONG&gt;String literal&lt;/STRONG&gt; after setting&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;options validvarname=any;&lt;/STRONG&gt;&lt;BR /&gt;data samp1;&lt;BR /&gt;input treeno nob b1-b3;&lt;BR /&gt;cards;&lt;BR /&gt;1 10 11 12&lt;BR /&gt;2 13 14 15&lt;BR /&gt;3 16 17 18&lt;BR /&gt;;&lt;BR /&gt;data want;&lt;BR /&gt;set samp1;&lt;BR /&gt;&lt;STRONG&gt;rename b1='1'n b2='2'n b3='3'n ;&lt;/STRONG&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen Srinivasan&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2017 13:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348513#M273419</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-04-09T13:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: convert column names to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348618#M273420</link>
      <description>&lt;P&gt;As Naveen says you need to use 'options validvarname=any' but you don't need the rename step. This will work just as well&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;
data samp1;
input treeno "1"n-"3"n;
cards;
1 10 11 12
2 13 14 15
3 16 17 18
;
run;

proc print data=samp1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I must say though that validvarname =any is usually used when handling data from an external source such as an RDBMS or Excel when normal SAS naming rules don't apply. If you start down the route of using this option you'll have to use it in every piece of code which references this file.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 08:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348618#M273420</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-04-10T08:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: convert column names to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348638#M273421</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32246"&gt;@ChrisBrooks&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;...&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;you'll have to use it in every piece of code which references this file&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;And that's why I've proposed to use labels and didn't even mention SAS name literals for variable names (they are to be avoided).&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 10:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-column-names-to-numbers/m-p/348638#M273421</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-04-10T10:32:02Z</dc:date>
    </item>
  </channel>
</rss>

