<?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 to create multiple proc mean within a population macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-multiple-proc-mean-within-a-population-macro/m-p/833502#M329494</link>
    <description>&lt;P&gt;I'm not sure what you actually want for output and find calling a single macro like that for each variable is likely inefficient at best and subject to a number of other problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might consider at single call to the Proc means, such as this:&lt;/P&gt;
&lt;PRE&gt;proc means data = sashelp.class  stackodsoutput
     n mean std median min max;
   class sex;
   var height weight;
   ods output summary=example;
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Which will create a data set with the statistics as variable names and a row variable with the name of the Var variables, one per row, per By or Class. Since you don't show a sort I don't know if you might be having By processing problems.&lt;/P&gt;
&lt;P&gt;If this type of out put will work for you then a single macro variable would be used to contain the names of all the variables you want on the VAR statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The STACKODSOUTPUT option used to make the statistics as variables will not work with the NOPRINT as the ODS OUTPUT statement requires some output sent to the results.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2022 06:27:37 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-09-15T06:27:37Z</dc:date>
    <item>
      <title>Macro to create multiple proc mean within a population macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-multiple-proc-mean-within-a-population-macro/m-p/833466#M329481</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Asking how to do a macro within a macro!&amp;nbsp; %POP is m y first macro, and %STAT is my macro within....I am asking how I need to se the bold part of this sample code (%STAT) so it executes within %POP.&amp;nbsp; Any help is appreciated!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro pop (flg, trt, num);&lt;BR /&gt;Data ADSL; &lt;BR /&gt;set ADAM.ADSL (where=(&amp;amp;flg='Y'));&lt;BR /&gt;&lt;BR /&gt;if &amp;amp;trt =: "ADI" then do;&lt;BR /&gt;txgrp = "A"; output;&lt;BR /&gt;txgrp = "T"; output;&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;if &amp;amp;trt =: "Placebo" then do;&lt;BR /&gt;txgrp = "B"; output;&lt;BR /&gt;txgrp = "T"; output;&lt;/P&gt;
&lt;P&gt;proc sort; by usubjid;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.........&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;%macro stat (var);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;proc means data= adsl noprint;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;by txgrp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var &amp;amp;var;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;output out= stat_&amp;amp;var n=n mean=mean std=std median=median min=min max=max;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;%mend stat;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;%stat (heightbl); %stat (weightbl); %stat (bsabl);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;.......&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data stats&amp;amp;num;&lt;BR /&gt;length _1 $50 text $200;&lt;/P&gt;
&lt;P&gt;set first (in=a)&lt;BR /&gt;stat_heightbl (in=b)&lt;BR /&gt;stat_weightbl (in=c) &lt;BR /&gt;stat_bsabl (in=d);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend pop;&lt;/P&gt;
&lt;P&gt;%pop(SAFFL, TRT01A, 1);&lt;BR /&gt;%pop(ITTFL, TRT01P, 2);&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 00:54:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-multiple-proc-mean-within-a-population-macro/m-p/833466#M329481</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2022-09-15T00:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create multiple proc mean within a population macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-multiple-proc-mean-within-a-population-macro/m-p/833502#M329494</link>
      <description>&lt;P&gt;I'm not sure what you actually want for output and find calling a single macro like that for each variable is likely inefficient at best and subject to a number of other problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might consider at single call to the Proc means, such as this:&lt;/P&gt;
&lt;PRE&gt;proc means data = sashelp.class  stackodsoutput
     n mean std median min max;
   class sex;
   var height weight;
   ods output summary=example;
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Which will create a data set with the statistics as variable names and a row variable with the name of the Var variables, one per row, per By or Class. Since you don't show a sort I don't know if you might be having By processing problems.&lt;/P&gt;
&lt;P&gt;If this type of out put will work for you then a single macro variable would be used to contain the names of all the variables you want on the VAR statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The STACKODSOUTPUT option used to make the statistics as variables will not work with the NOPRINT as the ODS OUTPUT statement requires some output sent to the results.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 06:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-multiple-proc-mean-within-a-population-macro/m-p/833502#M329494</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-15T06:27:37Z</dc:date>
    </item>
  </channel>
</rss>

