<?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: Interpolated Median Syntax (Macro &amp;amp; Loop) in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575423#M12858</link>
    <description>Look up CALL EXECUTE(). The documentation has an example of how to use it.</description>
    <pubDate>Mon, 22 Jul 2019 15:55:46 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-07-22T15:55:46Z</dc:date>
    <item>
      <title>Interpolated Median Syntax (Macro &amp; Loop)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575263#M12827</link>
      <description>&lt;P&gt;Dear SAS Base Gurus,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to work something out which I am sure SAS can do but not sure how to continue with &lt;EM&gt;incorporating loop within macro&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;Herewith the background as follows:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Got this code (&lt;STRONG&gt;IMReplicateForum.sas&lt;/STRONG&gt;) from mr.google;&lt;BR /&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*HAD THIS MACRO BELOW FROM SAS MASTER SIFU VIA GOOGLE*/
%macro intmed(dset, var);                                                             

proc means data=&amp;amp;dset. median noprint;
 var &amp;amp;var.;
 output out=outmed median=median;
run;

data _null_;
 set outmed;
 call symput("Median", median);
run;

data transform;
 set &amp;amp;dset. end=last;
 
 retain nl ne ng 0;
 median = &amp;amp;median.*1;
 
 if &amp;amp;var. &amp;lt; median then nl = nl+1;                                                    
 if &amp;amp;var. = median then ne = ne+1;                                                    
 if &amp;amp;var. &amp;gt; median then ng = ng+1;                                                    

 if last then do;
 if ne ne 0 then do;
 intmed = median + (ng-nl)/(2*ne);
 end;
 else if ne = 0 then do;
 intmed = median;
 end;
 output;
 end;
 label median = "Median"
 intmed = "Interpolated Median";
 keep median intmed;
run;

proc print data = transform label noobs;
 title "Value for Median and Interpolated Median";
 var median intmed;
run;
title "";
%mend;
                                                                                      


data Survey1 (keep=Question1AreUSatisfy);
	set Survey;
	if Question1AreUSatisfy; /*GET RID NULL/BLANK*/
	if ProgramID eq "MATH101";
run;
%intmed (Survey1, Question1AreUSatisfy);

*AT PRESENT THE MACRO JUST SHOWIN UP (OUTPUT) INTERPOLATED MEDIAN (IM) FIGURES ONE AT THE TIME BASED ON DATA SET.
*AS I AM SAS NEWBIE, I AM LOOKING ENLIGHTENMENT HOW TO DO THIS RATHER THAN 'MANUALLY' SUBSET DATA &amp;amp; POPULATE "IM" FIGURES.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;LI&gt;The macro run perfectly to produce Interpolated Median figures from Survey dataset (&lt;STRONG&gt;survey.sas7bdat&lt;/STRONG&gt;) attached.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro generate Interpolated Median (&lt;STRONG&gt;IM&lt;/STRONG&gt;) figures in output one at a time based&amp;nbsp;on unique ProgramID (Primary Key) subset data.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;What I try to achieve populate IM figures automatically in the list by add in new IM field consist figure from macro (e.g.: rather than hard coding IM figure one at a time back into dataset).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I am newbie with limited knowledge of SAS macro and loop, any enlightenment will be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 05:22:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575263#M12827</guid>
      <dc:creator>asp778ACU</dc:creator>
      <dc:date>2019-07-22T05:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: Interpolated Median Syntax (Macro &amp; Loop)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575308#M12831</link>
      <description>Should the program automatically process every numeric variable?&lt;BR /&gt;&lt;BR /&gt;Should a value of zero be excluded from the median calculations?</description>
      <pubDate>Mon, 22 Jul 2019 09:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575308#M12831</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-07-22T09:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Interpolated Median Syntax (Macro &amp; Loop)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575423#M12858</link>
      <description>Look up CALL EXECUTE(). The documentation has an example of how to use it.</description>
      <pubDate>Mon, 22 Jul 2019 15:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575423#M12858</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-22T15:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: Interpolated Median Syntax (Macro &amp; Loop)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575630#M12899</link>
      <description>&lt;P&gt;I think so, but unfortunately it's not the case.&lt;/P&gt;&lt;P&gt;I have to remove blank (e.g.: null) in data steps.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 03:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575630#M12899</guid>
      <dc:creator>asp778ACU</dc:creator>
      <dc:date>2019-07-23T03:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Interpolated Median Syntax (Macro &amp; Loop)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575631#M12900</link>
      <description>Shall deep dive &amp;amp; learn with it - thanks.</description>
      <pubDate>Tue, 23 Jul 2019 03:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Interpolated-Median-Syntax-Macro-amp-Loop/m-p/575631#M12900</guid>
      <dc:creator>asp778ACU</dc:creator>
      <dc:date>2019-07-23T03:48:11Z</dc:date>
    </item>
  </channel>
</rss>

