<?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: Choose the first 5 colums and rename with unknown variable names in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480230#M14989</link>
    <description>&lt;P&gt;Perfect! Thank you very much&lt;/P&gt;</description>
    <pubDate>Sun, 22 Jul 2018 13:03:57 GMT</pubDate>
    <dc:creator>SASAID</dc:creator>
    <dc:date>2018-07-22T13:03:57Z</dc:date>
    <item>
      <title>Choose the first 5 colums and rename with unknown variable names</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480198#M14985</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Is it possible to choose the first 5 columns of a table and to rename it without knowing the variable names ? Thanks a lot for answering my question.</description>
      <pubDate>Sat, 21 Jul 2018 23:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480198#M14985</guid>
      <dc:creator>SASAID</dc:creator>
      <dc:date>2018-07-21T23:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the first 5 colums and rename with unknown variable names</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480201#M14986</link>
      <description>&lt;P&gt;Can't completely answer this one without knowing a little more about what you're trying to do, but here's how to get the column names in order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	create table x as select name from dictionary.columns where
		libname = "SASHELP" and memname = "SHOES" and varnum &amp;lt;= 5
	order by varnum;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Jul 2018 00:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480201#M14986</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-07-22T00:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the first 5 colums and rename with unknown variable names</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480207#M14987</link>
      <description>&lt;P&gt;Yes it’s possible by reading the names into macro variables and using those instead.&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/222324"&gt;@SASAID&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;Is it possible to choose the first 5 columns of a table and to rename it without knowing the variable names ? Thanks a lot for answering my question.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jul 2018 01:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480207#M14987</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-22T01:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the first 5 colums and rename with unknown variable names</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480223#M14988</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222324"&gt;@SASAID&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Not sure about a use case for this other than "academic" but here you go:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  set sashelp.class;
run;

%let nvarsToChange=3;
proc sql noprint;
  select 
    cats(name,'=',substrn(cats('renamed_',name),1,32)) into :_rename_list separated by ' '
  from dictionary.columns
  where 
    libname='WORK' 
    and memname='HAVE'
    and varnum&amp;lt;=&amp;amp;nvarsToChange
  ;
quit;
%put %nrbquote(&amp;amp;_rename_list);

proc datasets lib=work nolist nowarn;
  modify have;
    rename &amp;amp;_rename_list;
  run;
  contents data=have order=varnum;
  run;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Jul 2018 11:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480223#M14988</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-07-22T11:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Choose the first 5 colums and rename with unknown variable names</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480230#M14989</link>
      <description>&lt;P&gt;Perfect! Thank you very much&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jul 2018 13:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Choose-the-first-5-colums-and-rename-with-unknown-variable-names/m-p/480230#M14989</guid>
      <dc:creator>SASAID</dc:creator>
      <dc:date>2018-07-22T13:03:57Z</dc:date>
    </item>
  </channel>
</rss>

