<?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: create variable from proc means to input into another proc means macro in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/create-variable-from-proc-means-to-input-into-another-proc-means/m-p/388987#M20270</link>
    <description>&lt;P&gt;I have to say I am not seeing a good reason to request the exact same statistic (max) once by itself and once with max and min in two different macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add an output out= in the proc means used in your TABS_stat_slide_risk macro then do the operation in a following data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think a single call to proc Report is likely able to do everything you are attempting here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You really need to provide example input data and what you want the final result to be. You are attempting in your call execute statements to run Proc Means in the middle of a Proc SQl statement and that just flat out is not going to work.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2017 22:20:27 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-08-17T22:20:27Z</dc:date>
    <item>
      <title>create variable from proc means to input into another proc means macro</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/create-variable-from-proc-means-to-input-into-another-proc-means/m-p/388953#M20268</link>
      <description>&lt;P&gt;With the following macros I create 2 different types of tables using a simple proc means approach. The code works fine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to modify the code to add a column to the&amp;nbsp;TABS_stat_per_axle proc means by dividing the MAX of &lt;SPAN&gt;TABS_stat_per_axle&amp;nbsp;&lt;/SPAN&gt;by the MAX of the&amp;nbsp;TABS_stat_slide_risk proc means.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro TABS_stat_per_axle(num);

	proc means data=WORK.QUERY_FOR_COUNTS MAX MAXDEC=2;
		where SORT_ORDER = &amp;amp;num;
		title "TABS Statistic - &amp;amp;num";
		Label STATISTIC_ATTRIBUTE_VAL="&amp;amp;num - distance in ft";
		class vehicle_no;
		var STATISTIC_ATTRIBUTE_VAL;
	run;

%mend TABS_stat_per_axle;
%macro TABS_stat_slide_risk(num);

	proc means data=WORK.QUERY_FOR_COUNTS MIN MAX MAXDEC=2;
		where SORT_ORDER = &amp;amp;num;
		title "TABS Statistic - &amp;amp;num";
		Label STATISTIC_ATTRIBUTE_VAL="&amp;amp;num - distance in ft";
		class vehicle_no;
		var STATISTIC_ATTRIBUTE_VAL;
	run;

%mend TABS_stat_slide_risk;
data _null_;
	array TABS_no[26] _temporary_ (1113:1138)
	;
	call execute('proc sql;');

	do i=1 to dim(TABS_no) while (TABS_no(i) ne .);
	if TABS_no(i)=1129 then
		call execute(cats('%nrstr(%TABS_stat_slide_risk)(',TABS_no(i),')'));
		else
		call execute(cats('%nrstr(%TABS_stat_per_axle)(',TABS_no(i),')'));
	end;

	call execute('quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 20:08:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/create-variable-from-proc-means-to-input-into-another-proc-means/m-p/388953#M20268</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-17T20:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: create variable from proc means to input into another proc means macro</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/create-variable-from-proc-means-to-input-into-another-proc-means/m-p/388987#M20270</link>
      <description>&lt;P&gt;I have to say I am not seeing a good reason to request the exact same statistic (max) once by itself and once with max and min in two different macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add an output out= in the proc means used in your TABS_stat_slide_risk macro then do the operation in a following data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think a single call to proc Report is likely able to do everything you are attempting here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You really need to provide example input data and what you want the final result to be. You are attempting in your call execute statements to run Proc Means in the middle of a Proc SQl statement and that just flat out is not going to work.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 22:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/create-variable-from-proc-means-to-input-into-another-proc-means/m-p/388987#M20270</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-17T22:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: create variable from proc means to input into another proc means macro</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/create-variable-from-proc-means-to-input-into-another-proc-means/m-p/390189#M20320</link>
      <description>&lt;P&gt;Hi Ballardw,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The portion of code below is in a macro that partially solved my issue. Thanks for your comment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	proc means noprint data=StatTable MAX MAXDEC=2;
		where SORT_ORDER = &amp;amp;num;
		title "TABS Statistic - &amp;amp;num";
		Label STATISTIC_ATTRIBUTE_VAL="&amp;amp;num - distance in ft";
		class vehicle_no;
		var STATISTIC_ATTRIBUTE_VAL ;
		output out=slide&amp;amp;num(drop=_type_ ) max=max;
	run;
	proc sql;
		create table slide&amp;amp;num as
		select A.*, B.max as max1129
		from slide&amp;amp;num A left join slide1129 B
		on A.vehicle_no=B.vehicle_no
		;
	quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Aug 2017 12:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/create-variable-from-proc-means-to-input-into-another-proc-means/m-p/390189#M20320</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-23T12:06:12Z</dc:date>
    </item>
  </channel>
</rss>

