<?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 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20448#M4232</link>
    <description>Thank you and I'll look into the PROC as well.&lt;BR /&gt;
Thanks again</description>
    <pubDate>Wed, 02 Mar 2011 23:23:02 GMT</pubDate>
    <dc:creator>R_A_G_</dc:creator>
    <dc:date>2011-03-02T23:23:02Z</dc:date>
    <item>
      <title>renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20445#M4229</link>
      <description>hi&lt;BR /&gt;
How do I rename all my variables when they just differ in their suffix. and rename the file at the same time/&lt;BR /&gt;
&lt;BR /&gt;
Thanks &lt;BR /&gt;
&lt;BR /&gt;
%let num=4&lt;BR /&gt;
&lt;BR /&gt;
DATA Q_Matrix_MIss;&lt;BR /&gt;
MODIFY Q_Matrix;&lt;BR /&gt;
	RENAME skills1-skills&amp;amp;num=att1-att&amp;amp;num; &lt;BR /&gt;
run;&lt;BR /&gt;
end;&lt;BR /&gt;
Ex:</description>
      <pubDate>Wed, 02 Mar 2011 17:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20445#M4229</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2011-03-02T17:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20446#M4230</link>
      <description>Hello R.A.G.,&lt;BR /&gt;
&lt;BR /&gt;
I do not understand your syntax but renaming can be done with this simple macro:&lt;BR /&gt;
[pre]%macro a(num=);&lt;BR /&gt;
data r;&lt;BR /&gt;
  set i;&lt;BR /&gt;
  %do i=1 %to &amp;amp;num;&lt;BR /&gt;
    rename skills&amp;amp;i=att&amp;amp;i;&lt;BR /&gt;
  %end;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend;&lt;BR /&gt;
%a(num=2)&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Wed, 02 Mar 2011 20:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20446#M4230</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-02T20:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20447#M4231</link>
      <description>Instead of creating additional datasets using a data step I would suggest looking into PROC DATASETS which lets you modify datasets and properties of the variables within the dataset.</description>
      <pubDate>Wed, 02 Mar 2011 22:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20447#M4231</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-03-02T22:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20448#M4232</link>
      <description>Thank you and I'll look into the PROC as well.&lt;BR /&gt;
Thanks again</description>
      <pubDate>Wed, 02 Mar 2011 23:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20448#M4232</guid>
      <dc:creator>R_A_G_</dc:creator>
      <dc:date>2011-03-02T23:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20449#M4233</link>
      <description>Although a proc datasets solution might be more efficient, the rename statement from your original code is valid.  There are two problems with the code you posted.  Since you are creating a new dataset instead of modifying an existing dataset in place, you need to use a set statement instead of a modify statement.  Also, the end statement is not needed.</description>
      <pubDate>Thu, 03 Mar 2011 10:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20449#M4233</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2011-03-03T10:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20450#M4234</link>
      <description>hello,&lt;BR /&gt;
&lt;BR /&gt;
a more general macro solution which takes advantage of dictionary tables:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
array skills{10};&lt;BR /&gt;
	do i=1 to 5;&lt;BR /&gt;
		do j=1 to 10;&lt;BR /&gt;
			skills{j}=ranuni(10);&lt;BR /&gt;
		end;&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
	select name into :all_var separated by ' ' from dictionary.columns&lt;BR /&gt;
	where libname=upcase('work') and memname=upcase('test') and name contains 'skills';&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
%macro change(new_suf);&lt;BR /&gt;
&lt;BR /&gt;
%let i=1;&lt;BR /&gt;
&lt;BR /&gt;
%do %until(%qscan(&amp;amp;all_var,%eval(&amp;amp;i)) eq %nrquote());&lt;BR /&gt;
	proc datasets library=work nolist;&lt;BR /&gt;
	modify test;&lt;BR /&gt;
	rename %qscan(&amp;amp;all_var,%eval(&amp;amp;i))=%sysfunc(cats(&amp;amp;new_suf,&amp;amp;i));&lt;BR /&gt;
	quit;&lt;BR /&gt;
	%let i=%eval(&amp;amp;i+1);&lt;BR /&gt;
%end;&lt;BR /&gt;
	&lt;BR /&gt;
&lt;BR /&gt;
%mend change;&lt;BR /&gt;
&lt;BR /&gt;
%change(att)&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Marius</description>
      <pubDate>Thu, 03 Mar 2011 11:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/renaming/m-p/20450#M4234</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-03T11:30:30Z</dc:date>
    </item>
  </channel>
</rss>

