<?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: Renaming the variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168434#M43586</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Astounding I got error for the following, how can I get rid of that error.&amp;nbsp; Is there any string function I should be using. data _NULL_;&amp;nbsp;&amp;nbsp; set sashelp.vcolumn;&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='TEST';&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if substr(name,1,3) = "MAT" and substr(name,14,1) ^= " "&amp;nbsp; then do;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if substr(name,14,1)&amp;nbsp; = "1"&amp;nbsp; then do;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc datasets; modify TEST; rename ' || name || '= MA-ABC.GROWTH' || substr(name,6,13) || ';');&amp;nbsp; end; end; run; I got error for MA-ABC.GROWTH.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Oct 2014 17:16:24 GMT</pubDate>
    <dc:creator>pp2014</dc:creator>
    <dc:date>2014-10-01T17:16:24Z</dc:date>
    <item>
      <title>Renaming the variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168428#M43580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do I rename the Variables based on the following: I have variables like&amp;nbsp;&amp;nbsp;&amp;nbsp; MAT___09_20091&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAT___09_20092&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAT___09_20093 Based on the last character 1 (abc) , 2 (xyz)&amp;nbsp; and&amp;nbsp; 3 (hgk), I want to rename them as abc_09_2009, xyz_09_2009, and&amp;nbsp;&amp;nbsp; hgk_09_2009. I may have various variables like this MAT___09_20101, MAT___09_20102 and so on.&amp;nbsp; Also I want to rename the following field as&amp;nbsp; MAT____09_2009, MAT____09_2010&amp;nbsp; as Growth_09_2009, Growth_09_2010 Thanks for any help..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 15:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168428#M43580</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2014-10-01T15:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming the variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168429#M43581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;any help???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 15:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168429#M43581</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2014-10-01T15:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming the variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168430#M43582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried the following but it does not work.&amp;nbsp; What I am doing wrong data want;&amp;nbsp;&amp;nbsp; set sashelp.vcolumn;&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='TEST';&amp;nbsp;&amp;nbsp; if substr(name,1,3) = "MAT" and substr(name,7,1) = "_"&amp;nbsp; then&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc datasets ;modify TEST;rename&amp;nbsp; name&amp;nbsp; = "Growth" || substr(name,7)'); run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 16:34:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168430#M43582</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2014-10-01T16:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming the variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168431#M43583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The approach looks quite feasible.&amp;nbsp; One area where you are encountering trouble is the code being passed through CALL EXECUTE.&amp;nbsp; In your DATA step, NAME refers to the name of a variable within sashelp.vcolumn.&amp;nbsp; It should not be in quotes if you want it to be replaced with the NAME's value.&amp;nbsp; So this string would be closer to what you need:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call execute('proc datasets; modify TEST; rename ' || name || '= Growth' || substr(name,7) || ';');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 16:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168431#M43583</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-10-01T16:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming the variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168432#M43584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Astounding it worked..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 16:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168432#M43584</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2014-10-01T16:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming the variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168433#M43585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great.&amp;nbsp; A few tweaks then ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your data set WANT does not need to be saved.&amp;nbsp; You could use data _null_ instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code is generating many instances of PROC DATASETS.&amp;nbsp; You could generate just one instead:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if _n_=1 then call execute('proc datasets; modify TEST;');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then the later IF/THEN statements could generate just the RENAME statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 17:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168433#M43585</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-10-01T17:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming the variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168434#M43586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Astounding I got error for the following, how can I get rid of that error.&amp;nbsp; Is there any string function I should be using. data _NULL_;&amp;nbsp;&amp;nbsp; set sashelp.vcolumn;&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='TEST';&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if substr(name,1,3) = "MAT" and substr(name,14,1) ^= " "&amp;nbsp; then do;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if substr(name,14,1)&amp;nbsp; = "1"&amp;nbsp; then do;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc datasets; modify TEST; rename ' || name || '= MA-ABC.GROWTH' || substr(name,6,13) || ';');&amp;nbsp; end; end; run; I got error for MA-ABC.GROWTH.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 17:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168434#M43586</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2014-10-01T17:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming the variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168435#M43587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, names of variables in SAS are restricted to underscores, letters and numbers.&amp;nbsp; Dashes and periods would not be valid characters for naming a variable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are ways around this, but they make future programming very cumbersome.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 18:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Renaming-the-variables/m-p/168435#M43587</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-10-01T18:41:22Z</dc:date>
    </item>
  </channel>
</rss>

