<?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: macro rename variable problem in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64374#M1543</link>
    <description>It looks like the problem is most likely because SAS thinks &amp;amp;var_median is a macro variable (as in %let var_median=Variable; ).  You need a period at the end of your macro variable so that SAS will look up the correct macro variable name.  It also looks like the &amp;amp;&amp;amp; is redundant in your code.&lt;BR /&gt;
&lt;BR /&gt;
So try using:&lt;BR /&gt;
&lt;BR /&gt;
set tmp1(rename=&amp;amp;var._median=xmedian);</description>
    <pubDate>Wed, 19 Jan 2011 18:43:13 GMT</pubDate>
    <dc:creator>RickM</dc:creator>
    <dc:date>2011-01-19T18:43:13Z</dc:date>
    <item>
      <title>macro rename variable problem</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64373#M1542</link>
      <description>dear all,&lt;BR /&gt;
&lt;BR /&gt;
When I use the following code to rename a variable name, it works well.&lt;BR /&gt;
&lt;BR /&gt;
  proc means median maxdec=2 data=tmp;&lt;BR /&gt;
        var x1;&lt;BR /&gt;
       class group;&lt;BR /&gt;
  ods output summary=tmp1;&lt;BR /&gt;
  data tmp1;set tmp1(rename=x_median=xmedian);&lt;BR /&gt;
  run;&lt;BR /&gt;
&lt;BR /&gt;
When I use a following macro to rename the variable name, it doesn't work any way. &lt;BR /&gt;
&lt;BR /&gt;
%macro rename(data=,var=,group=);&lt;BR /&gt;
proc means median maxdec=2 data=&amp;amp;data;&lt;BR /&gt;
        var &amp;amp;var;&lt;BR /&gt;
       class &amp;amp;group;&lt;BR /&gt;
  ods output summary=tmp1;&lt;BR /&gt;
  data tmp1;set tmp1(rename=&amp;amp;&amp;amp;var_median=xmedian);&lt;BR /&gt;
  run;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
How can I to revise the macro? Thanks in advance for your time and patience.</description>
      <pubDate>Wed, 19 Jan 2011 17:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64373#M1542</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-01-19T17:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: macro rename variable problem</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64374#M1543</link>
      <description>It looks like the problem is most likely because SAS thinks &amp;amp;var_median is a macro variable (as in %let var_median=Variable; ).  You need a period at the end of your macro variable so that SAS will look up the correct macro variable name.  It also looks like the &amp;amp;&amp;amp; is redundant in your code.&lt;BR /&gt;
&lt;BR /&gt;
So try using:&lt;BR /&gt;
&lt;BR /&gt;
set tmp1(rename=&amp;amp;var._median=xmedian);</description>
      <pubDate>Wed, 19 Jan 2011 18:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64374#M1543</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2011-01-19T18:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: macro rename variable problem</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64375#M1544</link>
      <description>Many thanks for your help. I have tried to replace the &amp;amp;var_median with &amp;amp;var._median or &amp;amp;&amp;amp;var_median, but sas doesn't work.</description>
      <pubDate>Thu, 20 Jan 2011 01:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64375#M1544</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-01-20T01:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: macro rename variable problem</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64376#M1545</link>
      <description>Suggest the OP post a reply with the SAS log revealing the exact error so we can better understand what this means: "sas doesn't work"&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 20 Jan 2011 11:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64376#M1545</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-01-20T11:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: macro rename variable problem</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64377#M1546</link>
      <description>Hi wmqy,&lt;BR /&gt;
&lt;BR /&gt;
Does the variable in tmp1 must be xmedian? Can it be  medianx?&lt;BR /&gt;
&lt;BR /&gt;
If medianx is ok, try the following code:&lt;BR /&gt;
&lt;BR /&gt;
%macro rename(data=,var=,group=);&lt;BR /&gt;
proc means maxdec=2 data=&amp;amp;data noprint;&lt;BR /&gt;
  var &amp;amp;var;&lt;BR /&gt;
  class &amp;amp;group;&lt;BR /&gt;
  output out=tmp1 median(&amp;amp;var)=median&amp;amp;var;&lt;BR /&gt;
run;&lt;BR /&gt;
data tmp1;&lt;BR /&gt;
  set tmp1(where=(_Type_ NE 0));&lt;BR /&gt;
  drop _Type_ _Freq_;&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 20 Jan 2011 19:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/macro-rename-variable-problem/m-p/64377#M1546</guid>
      <dc:creator>statsplank</dc:creator>
      <dc:date>2011-01-20T19:30:46Z</dc:date>
    </item>
  </channel>
</rss>

