<?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: SOS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64572#M14043</link>
    <description>Should we assume that the actual problem has a large enough number of variables to preclude just coding a rename statement?  Are you trying to build a macro that will rename all variables in a data set that start with some given string?</description>
    <pubDate>Thu, 20 Jan 2011 02:43:16 GMT</pubDate>
    <dc:creator>ArtC</dc:creator>
    <dc:date>2011-01-20T02:43:16Z</dc:date>
    <item>
      <title>SOS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64570#M14041</link>
      <description>Dear all,&lt;BR /&gt;
&lt;BR /&gt;
I have a data set like this.&lt;BR /&gt;
group x1_N x1_nmiss x1_mean x1_stddev x1_median&lt;BR /&gt;
1         201       0          15.3          5.2           14.9&lt;BR /&gt;
2         199       0          17.6          4.9           17.5&lt;BR /&gt;
3         203       0          18.9          5.7            18.6&lt;BR /&gt;
&lt;BR /&gt;
How can I use the &lt;B&gt;macro&lt;/B&gt; to remove the character "x1_" of every variable(to rename x1_nmiss as nmiss,etc.)? I can finish the work with &lt;B&gt;data step&lt;/B&gt; very well, but when I try to use macro, the problem occures. Who can give me a hand? Thanks in advance for your time and patience.</description>
      <pubDate>Thu, 20 Jan 2011 02:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64570#M14041</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-01-20T02:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: SOS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64571#M14042</link>
      <description>I am waiting for your reply on line. Thanks again.</description>
      <pubDate>Thu, 20 Jan 2011 02:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64571#M14042</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-01-20T02:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: SOS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64572#M14043</link>
      <description>Should we assume that the actual problem has a large enough number of variables to preclude just coding a rename statement?  Are you trying to build a macro that will rename all variables in a data set that start with some given string?</description>
      <pubDate>Thu, 20 Jan 2011 02:43:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64572#M14043</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-01-20T02:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: SOS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64573#M14044</link>
      <description>[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
 infile datalines dlm=' ';&lt;BR /&gt;
 input group x1_N x1_nmiss  x1_mean  x1_stddev  x1_median;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 201 0 15.3 5.2 14.9&lt;BR /&gt;
2 199 0 17.6 4.9 17.5&lt;BR /&gt;
3 203 0 18.9 5.7 18.6&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
options mprint mlogic symbolgen;&lt;BR /&gt;
%macro rename;&lt;BR /&gt;
proc sql ;&lt;BR /&gt;
 select name from dictionary.columns where libname='WORK' and memname='TEMP' and name like 'x1%';&lt;BR /&gt;
 select name &lt;BR /&gt;
   into : name1 - : name&amp;amp;sqlobs.&lt;BR /&gt;
    from dictionary.columns where libname='WORK' and memname='TEMP' and name like 'x1%';&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc datasets library=work memtype=data nolist;&lt;BR /&gt;
 modify temp;&lt;BR /&gt;
  rename %do k=1 %to &amp;amp;sqlobs.;&lt;BR /&gt;
          &amp;amp;&amp;amp;name&amp;amp;k.. = %sysfunc(scan( &amp;amp;&amp;amp;name&amp;amp;k.. ,2,_) )&lt;BR /&gt;
        %end;&lt;BR /&gt;
        ;&lt;BR /&gt;
quit;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
%rename&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 20 Jan 2011 06:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64573#M14044</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-01-20T06:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: SOS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64574#M14045</link>
      <description>Dear Ksharp,&lt;BR /&gt;
&lt;BR /&gt;
It's very kind of you to reply quickly and efficiently. Your program works very well. Many many thanks for your help.</description>
      <pubDate>Thu, 20 Jan 2011 08:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64574#M14045</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-01-20T08:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: SOS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64575#M14046</link>
      <description>Maybe this code is better.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
 infile datalines dlm=' ';&lt;BR /&gt;
 input group x1_N x1_nmiss  x1_mean  x1_stddev  x1_median;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 201 0 15.3 5.2 14.9&lt;BR /&gt;
2 199 0 17.6 4.9 17.5&lt;BR /&gt;
3 203 0 18.9 5.7 18.6&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
options mprint mlogic symbolgen;&lt;BR /&gt;
%macro rename;&lt;BR /&gt;
proc sql ;&lt;BR /&gt;
 select name from dictionary.columns where libname='WORK' and memname='TEMP' and name like 'x1%';&lt;BR /&gt;
 select catx(' ',name,'=',scan(name,2,'_')) &lt;BR /&gt;
   into : name1 - : name&amp;amp;sqlobs.&lt;BR /&gt;
    from dictionary.columns where libname='WORK' and memname='TEMP' and name like 'x1%';&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc datasets library=work memtype=data nolist;&lt;BR /&gt;
 modify temp;&lt;BR /&gt;
  rename %do k=1 %to &amp;amp;sqlobs.;&lt;BR /&gt;
          &amp;amp;&amp;amp;name&amp;amp;k..&lt;BR /&gt;
        %end;&lt;BR /&gt;
        ;&lt;BR /&gt;
quit;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
%rename&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 20 Jan 2011 09:07:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SOS/m-p/64575#M14046</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-01-20T09:07:12Z</dc:date>
    </item>
  </channel>
</rss>

