<?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: My Macro resolved to previous result while log resolves to current. Any help? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/My-Macro-resolved-to-previous-result-while-log-resolves-to/m-p/414098#M101424</link>
    <description>&lt;P&gt;Spell title correctly throughout.&amp;nbsp; Your second one is spelled wrong.&amp;nbsp; Add a RUN statement at the end.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Nov 2017 18:27:48 GMT</pubDate>
    <dc:creator>WarrenKuhfeld</dc:creator>
    <dc:date>2017-11-16T18:27:48Z</dc:date>
    <item>
      <title>My Macro resolved to previous result while log resolves to current. Any help?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/My-Macro-resolved-to-previous-result-while-log-resolves-to/m-p/413857#M101335</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint symbolgen;
&lt;BR /&gt;data have;
input EMPNO Salary empcode $;
cards;
111 4000 A
112 6000 A
114 2000 A
115 8000 A
223 2000 B
226 1000 B
228 3000 B
300 500 C
333 700 C
345 300 C
356 200 C
320 700 C
;
run;

%macro highest(num=);
     %global g_num;
     %let g_num = &amp;amp;num;&lt;BR /&gt;
     proc sort data=have;
           by descending salary;
     run;&lt;BR /&gt;
     data want;
        set have;
         if _n_ = &amp;amp;g_num then do;
         output;
         stop;
         end;
     run;
     proc print data = want;
     &lt;BR /&gt;       %if &amp;amp;g_num = 1 %then %do;
           title "This is 1st Highest Salary";
       %end;
       %else %if &amp;amp;g_num = 2 %then %do; 
           tilte "This is 2nd Highest Salary";
       %end;
       %else %if &amp;amp;g_num = 3 %then %do;
           title "This is 3rd Highest Salary";
       %end;
       %else %do;
           title "This is &amp;amp;g_num.th Highest Salary";
       %end;&lt;BR /&gt;
    %symdel g_num;&lt;BR /&gt;
%mend highest;&lt;BR /&gt;
%highest(num=11)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to print nth highest salary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At first my program executes fine. And If you execute changing the parameter value(num) in macro&lt;STRONG&gt;&lt;EM&gt; %highest&lt;/EM&gt;&lt;/STRONG&gt;, along with macro it yields correct results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I execute only the line&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt; %highest(num=11)&lt;/EM&gt; &lt;/STRONG&gt;by changing the value, without including the macro definition in the execution, it shows results of previous value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's wrong with this code ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vaibhav&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 01:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/My-Macro-resolved-to-previous-result-while-log-resolves-to/m-p/413857#M101335</guid>
      <dc:creator>arunvaibhav2</dc:creator>
      <dc:date>2017-11-16T01:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: My Macro resolved to previous result while log resolves to current. Any help?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/My-Macro-resolved-to-previous-result-while-log-resolves-to/m-p/414098#M101424</link>
      <description>&lt;P&gt;Spell title correctly throughout.&amp;nbsp; Your second one is spelled wrong.&amp;nbsp; Add a RUN statement at the end.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 18:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/My-Macro-resolved-to-previous-result-while-log-resolves-to/m-p/414098#M101424</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-11-16T18:27:48Z</dc:date>
    </item>
  </channel>
</rss>

