<?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: Rename all variables. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558958#M156040</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271996"&gt;@hiteshchauhan1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;isn't dictionary.columns actually contains all the variables which we define in this statement below:&lt;BR /&gt;where libname = "" and memname="").&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The DATA has the information for the datasets selected by that where clause but what observations you select won't change the structure of the DICTIONARY.COLUMNS dataset.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;9925  proc sql;
9926  describe table dictionary.columns;
NOTE: SQL table DICTIONARY.COLUMNS was created like:

create table DICTIONARY.COLUMNS
  (
   libname char(8) label='Library Name',
   memname char(32) label='Member Name',
   memtype char(8) label='Member Type',
   name char(32) label='Column Name',
   type char(4) label='Column Type',
   length num label='Column Length',
   npos num label='Column Position',
   varnum num label='Column Number in Table',
   label char(256) label='Column Label',
   format char(49) label='Column Format',
   informat char(49) label='Column Informat',
   idxusage char(9) label='Column Index Type',
   sortedby num label='Order in Key Sequence',
   xtype char(12) label='Extended Type',
   notnull char(3) label='Not NULL?',
   precision num label='Precision',
   scale num label='Scale',
   transcode char(3) label='Transcoded?',
   diagnostic char(256) label='Diagnostic Message from File Open Attempt'
  );
&lt;/PRE&gt;</description>
    <pubDate>Wed, 15 May 2019 14:21:26 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-05-15T14:21:26Z</dc:date>
    <item>
      <title>Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/500828#M133408</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to rename all variables by adding a suffix _V1. I have the following codes using sashelp.clasa&amp;nbsp;as an example. The codes have error&amp;nbsp;messages.&lt;/P&gt;&lt;P&gt;ERROR 73-322: Expecting an =.&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please&amp;nbsp;suggest. Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data class;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc contents data=class out=vars(keep=name);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data vars (keep=newname);&lt;BR /&gt;set vars;&lt;BR /&gt;newname=trim(left(name))||"_V1";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select trim(left(newname))&lt;BR /&gt;into :renam_list separated by " "&lt;BR /&gt;from vars;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc datasets library = work nolist;&lt;BR /&gt;modify class;&lt;BR /&gt;rename &amp;amp;renam_list;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc contents data =class;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 16:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/500828#M133408</guid>
      <dc:creator>CHL0320</dc:creator>
      <dc:date>2018-10-02T16:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/500830#M133409</link>
      <description>&lt;P&gt;Your rename has to be name=name_V1. Using dictionary table instead&amp;nbsp; is much easier.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
set sashelp.class;
run;
proc sql;
select name||"="||cats(name,'_V1') into:rename_list separated by " "
from dictionary.columns
where libname="WORK" and memname="CLASS";
quit; 

proc datasets library = work nolist;
modify class;
rename &amp;amp;rename_list;
quit;


proc contents data =class;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Oct 2018 16:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/500830#M133409</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-02T16:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/500839#M133411</link>
      <description>&lt;P&gt;Since you are attempting to add 3 characters to the name do you have any variable names&amp;nbsp;that currently have a length of 30 or greater? The result of adding _V1 would exceed the length of variables.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 16:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/500839#M133411</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-02T16:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558843#M156004</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While running the same code with a few tweaks here and there according to my requirements i am getting the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR: The following columns were not found in the contributing tables:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using a dataset which has been output to a folder and using that libname instead of 'work' in the code .below is the code that i am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname H "Path of the library";&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select cats(class,'=','new_',class)&lt;BR /&gt;into :list&lt;BR /&gt;separated by ' '&lt;BR /&gt;from dictionary.columns&lt;BR /&gt;where libname = 'H' and memname = 'Data;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me with this issue. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 09:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558843#M156004</guid>
      <dc:creator>hiteshchauhan1</dc:creator>
      <dc:date>2019-05-15T09:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558944#M156033</link>
      <description>where libname="H" and memname="DATA";Both libname and memname need to be capitalized.&amp;nbsp;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 May 2019 14:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558944#M156033</guid>
      <dc:creator>CHL0320</dc:creator>
      <dc:date>2019-05-15T14:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558950#M156036</link>
      <description>&lt;P&gt;I tried that too ... btw my code is working now and the issue is really weird. i will try to explain the best i can. So, i was using an already created dataset. apparently you need to create a new variable using a data statement .... first create a new dataset and set it to your origional data and then create a new variable in the newly created dataset,&amp;nbsp; then use that new variable in select cats() statement then it will work. Happened with me and it is really weird.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 14:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558950#M156036</guid>
      <dc:creator>hiteshchauhan1</dc:creator>
      <dc:date>2019-05-15T14:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558951#M156037</link>
      <description>&lt;P&gt;There is no variable named CLASS in DICTIONARY.COLUMNS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume you want the variable named NAME that has the variable names.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 14:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558951#M156037</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-15T14:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558953#M156039</link>
      <description>&lt;BR /&gt;isn't dictionary.columns actually contains all the variables which we define in this statement below:&lt;BR /&gt;where libname = "" and memname="").</description>
      <pubDate>Wed, 15 May 2019 14:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558953#M156039</guid>
      <dc:creator>hiteshchauhan1</dc:creator>
      <dc:date>2019-05-15T14:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558958#M156040</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271996"&gt;@hiteshchauhan1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;isn't dictionary.columns actually contains all the variables which we define in this statement below:&lt;BR /&gt;where libname = "" and memname="").&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The DATA has the information for the datasets selected by that where clause but what observations you select won't change the structure of the DICTIONARY.COLUMNS dataset.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;9925  proc sql;
9926  describe table dictionary.columns;
NOTE: SQL table DICTIONARY.COLUMNS was created like:

create table DICTIONARY.COLUMNS
  (
   libname char(8) label='Library Name',
   memname char(32) label='Member Name',
   memtype char(8) label='Member Type',
   name char(32) label='Column Name',
   type char(4) label='Column Type',
   length num label='Column Length',
   npos num label='Column Position',
   varnum num label='Column Number in Table',
   label char(256) label='Column Label',
   format char(49) label='Column Format',
   informat char(49) label='Column Informat',
   idxusage char(9) label='Column Index Type',
   sortedby num label='Order in Key Sequence',
   xtype char(12) label='Extended Type',
   notnull char(3) label='Not NULL?',
   precision num label='Precision',
   scale num label='Scale',
   transcode char(3) label='Transcoded?',
   diagnostic char(256) label='Diagnostic Message from File Open Attempt'
  );
&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2019 14:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/558958#M156040</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-15T14:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/575482#M162792</link>
      <description />
      <pubDate>Mon, 22 Jul 2019 17:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/575482#M162792</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-22T17:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/625857#M184529</link>
      <description>&lt;P&gt;This is helpful thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you let me know how to do the same for columns that have space in the variable name ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 14:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/625857#M184529</guid>
      <dc:creator>akosyan</dc:creator>
      <dc:date>2020-02-19T14:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/625864#M184532</link>
      <description>&lt;P&gt;Use the NLITERAL() function around the NAME variable in the SQL query.&amp;nbsp; If the value follows normal SAS naming rules then it is not changed. Otherwise it is enclosed in quotes and the letter N is appended.&amp;nbsp; So a name like A.B will become 'A.B'n.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 15:08:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables/m-p/625864#M184532</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-19T15:08:01Z</dc:date>
    </item>
  </channel>
</rss>

