<?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 multiple variables without specifying them in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680718#M205785</link>
    <description>&lt;P&gt;Don't keep data (dates) in structure (variable names). Transpose to a long layout, convert the _name_ variable to a SAS date, and assign a display format to your taste.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want code for that, supply example data in usable form (data step with datalines). Use the the "little running man" button to post the code.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Sep 2020 15:21:05 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-09-01T15:21:05Z</dc:date>
    <item>
      <title>Renaming multiple variables without specifying them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680716#M205783</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an easy way to rename all variables in a dataset without having to write their names?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say I have variables such as 202001, 202002, 202003 and so on. But I want to rename them all at once so that they are renamed as Jan-20, Feb-20, Mar-20 and so on.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought about using an array of variable names to replace the current ones but not sure if that will be easy as in Python or R.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would be the easiest way to tackle this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;JL&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 15:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680716#M205783</guid>
      <dc:creator>jlee8</dc:creator>
      <dc:date>2020-09-01T15:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming multiple variables without specifying them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680718#M205785</link>
      <description>&lt;P&gt;Don't keep data (dates) in structure (variable names). Transpose to a long layout, convert the _name_ variable to a SAS date, and assign a display format to your taste.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want code for that, supply example data in usable form (data step with datalines). Use the the "little running man" button to post the code.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 15:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680718#M205785</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-01T15:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming multiple variables without specifying them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680722#M205789</link>
      <description>&lt;P&gt;Ideally you can back up a few steps and avoid this issue....is there a step where you transpose or restructure the data?&lt;/P&gt;
&lt;P&gt;If so, in that step you can dynamically specify your names and labels to generate what you need. Usually 202001 is not a valid SAS variable name as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second option, is to clean up after the fact and use the SASHELP.VCOLUMN or dictionary.column table to dynamically generate your rename and label statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would highly suggest the usage of labels instead of variable names such as Jan-20.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/343772"&gt;@jlee8&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an easy way to rename all variables in a dataset without having to write their names?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say I have variables such as 202001, 202002, 202003 and so on. But I want to rename them all at once so that they are renamed as Jan-20, Feb-20, Mar-20 and so on.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought about using an array of variable names to replace the current ones but not sure if that will be easy as in Python or R.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What would be the easiest way to tackle this problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;
&lt;P&gt;JL&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 15:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680722#M205789</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-09-01T15:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming multiple variables without specifying them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680727#M205792</link>
      <description>&lt;P&gt;Are you importing data from excel with first line containing those dates as&amp;nbsp; labels&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to be treated in sas as variable names?&lt;/P&gt;
&lt;P&gt;Can you post a sample of your data in a data step with datalines?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 15:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680727#M205792</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-01T15:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming multiple variables without specifying them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680745#M205805</link>
      <description>&lt;P&gt;Agreeing with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;, don't structure your data like this.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Even in the case suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;where you receive an Excel file with this poor structure, you should make the data set long with the dates as a value of a variable (which is much easier to handle in SAS code) instead of modifying the variable names to contain Jan or Feb or the like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 16:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680745#M205805</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-01T16:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming multiple variables without specifying them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680946#M205919</link>
      <description>&lt;P&gt;&lt;SPAN&gt;202001, 202002, 202003 are not valid sas variable name .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;options validvarname=any;
data have;
input  '202001'n '202002'n '202003'n;
cards;
1 2 3
;


proc transpose data=have(obs=0) out=temp;
var _all_;
run;
data temp;
 set temp;
 name=put(input(_name_,yymmn6.),monyy7.)	;
run;
proc sql noprint;
select catx('=',nliteral(_name_),name) into :rename separated by ' ' from temp;
quit;
proc datasets library=work nolist nodetails;
modify have;
rename &amp;amp;rename;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Sep 2020 12:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-multiple-variables-without-specifying-them/m-p/680946#M205919</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-09-02T12:37:45Z</dc:date>
    </item>
  </channel>
</rss>

