<?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: beginner needs help with min/max function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426089#M104967</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185631"&gt;@sandi98&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thaanks for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't used it because my instructor says I must use a data step for this.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Well, since everyone here told you not to use a data step, but your instructor says you have to, you're probably going to have to take a try at creating the code on your own to do this in a data step. So show us your code, and we can probably (reluctantly) help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not clear to me what the point of such a homework assignment is anyway ... student must learn inefficient and tedious method of computing simple statistics in SAS, that can be easily computed with 5 lines of code using the proper SAS PROC. You can tell your instructor that I said so.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jan 2018 13:48:26 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-01-09T13:48:26Z</dc:date>
    <item>
      <title>beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426077#M104958</link>
      <description>&lt;P&gt;Hey! I'm not the best programmer, nor I've ever post something here as a student.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help by a little task I've got at work. I should use the data step for creating a table "durchschnitt2" with&amp;nbsp;the&amp;nbsp;MIN, MAX and AVG für every numeric value&amp;nbsp;for each sex (M and F) using the SASHELP.CLASS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already sovled the task by using the proc SQL. This is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; durchschnitt1 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;sex,&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;min(age) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; age_min,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;max(age) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; age_max,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;avg(age) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; age_avg format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;commax10.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;min(height) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; height_min format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;commax10.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;max(height) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; height_max format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;commax10.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;avg(height) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; height_avg format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;commax10.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;min(weight) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; weight_min format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;commax10.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;max(weight) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; weight_max format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;commax10.2&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;avg(weight) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; weight_avg format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;commax10.2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sashelp.class&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; sex;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should I do this in a data step?&lt;/P&gt;&lt;P&gt;Thank your for helping.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:31:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426077#M104958</guid>
      <dc:creator>sandi98</dc:creator>
      <dc:date>2018-01-09T13:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426080#M104959</link>
      <description>&lt;P&gt;Why not use PROC MEANS like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means noprint data=sashelp.class min max mean;
	output out=want(keep=_STAT_ age height weight);
	var age height weight;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426080#M104959</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-09T13:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426081#M104960</link>
      <description>&lt;P&gt;Is this for some homework?&amp;nbsp; The reason being to get summary stats you would normally use proc means or summary as that is what they are for:&lt;/P&gt;
&lt;PRE&gt;proc sort data=sashelp.class out=class;
  by sex;
run;

proc means data=class min max mean;
  by sex;
  var age height weight;
  output out=want;
run;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426081#M104960</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-09T13:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426082#M104961</link>
      <description>&lt;P&gt;I would highly discourage using a DATA STEP to do this, because SAS has already created the proper PROC to create these statistics. Use SAS PROCs when available. (It will save you time, and all the debugging has been built into the creation of the PROC)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary nway data=sashelp.class;
    class sex;
	var age height weight;
	output out=stats min= max= mean= /autoname;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:40:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426082#M104961</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-01-09T13:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426084#M104963</link>
      <description>&lt;P&gt;The datastep is not the tool of choice to calculate these univariate statistics. Your SQL is quite appropriate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The better non-SQL way would be to use proc means. This procedure can calculate your stats (and then some) and&amp;nbsp;output them to a dataset with ease. I will give you the code&amp;nbsp;I do not want to withhold an opportunity&amp;nbsp;to read the docs and learn.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;-- Jan.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426084#M104963</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2018-01-09T13:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426085#M104964</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185631"&gt;@sandi98&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc summary would you give you the stats as additional columns&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=sashelp.class nway;
	class sex;
	var age height weight;
	output out=durchschnitt1(drop=_:) 
		min=age_min height_min weight_min 
		max=age_max height_max weight_max
		mean=age_avg height_avg weight_avg;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Ahmed&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426085#M104964</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2018-01-09T13:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426086#M104965</link>
      <description>&lt;P&gt;Thaanks for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't used it because my instructor says I must use a data step for this.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426086#M104965</guid>
      <dc:creator>sandi98</dc:creator>
      <dc:date>2018-01-09T13:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426087#M104966</link>
      <description>&lt;P&gt;If the goal of your exercise is learning data step techniques, then you need to first sort the dataset by your group variable.&lt;/P&gt;
&lt;P&gt;Then you use by-processing and the first. and last. automatic variables, and retained variables for counters and sums. At the end of each by group, calculate the average and output.&lt;/P&gt;
&lt;P&gt;Do google searches for&lt;/P&gt;
&lt;P&gt;sas proc sort&lt;/P&gt;
&lt;P&gt;sas by statement&lt;/P&gt;
&lt;P&gt;sas first. last.&lt;/P&gt;
&lt;P&gt;sas retain statement&lt;/P&gt;
&lt;P&gt;sas output statement&lt;/P&gt;
&lt;P&gt;sas keep statement&lt;/P&gt;
&lt;P&gt;sas keep dataset option&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426087#M104966</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-09T13:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426089#M104967</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185631"&gt;@sandi98&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thaanks for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't used it because my instructor says I must use a data step for this.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Well, since everyone here told you not to use a data step, but your instructor says you have to, you're probably going to have to take a try at creating the code on your own to do this in a data step. So show us your code, and we can probably (reluctantly) help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not clear to me what the point of such a homework assignment is anyway ... student must learn inefficient and tedious method of computing simple statistics in SAS, that can be easily computed with 5 lines of code using the proper SAS PROC. You can tell your instructor that I said so.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426089#M104967</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-01-09T13:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426091#M104968</link>
      <description>&lt;P&gt;You can say "homework".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking to use the PROC MEAN first, but my&amp;nbsp;instructur said I should do it with a data step. I don't know why...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426091#M104968</guid>
      <dc:creator>sandi98</dc:creator>
      <dc:date>2018-01-09T13:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426096#M104970</link>
      <description>&lt;P&gt;Thank you! I will search for this.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 13:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426096#M104970</guid>
      <dc:creator>sandi98</dc:creator>
      <dc:date>2018-01-09T13:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426101#M104971</link>
      <description>&lt;P&gt;It's also seems weird for myself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I spend the last hours by desperately getting informations on google. That's all I have for a (false) data step. The MAX and AVG are missing. Even the MIN doesn't work, because it's not finished.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data durchschnitt2;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;by Sex;&lt;/P&gt;&lt;P&gt;retain age_min;&lt;BR /&gt;if first.sex then do;&lt;BR /&gt;age=age_min;&lt;BR /&gt;end;&lt;BR /&gt;if last.sex then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print data=durchschnitt2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 14:06:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426101#M104971</guid>
      <dc:creator>sandi98</dc:creator>
      <dc:date>2018-01-09T14:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426106#M104972</link>
      <description>&lt;P&gt;That's a start. Let's see where you went wrong:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data durchschnitt2;
set sashelp.class;
by sex;
retain age_min;
if first.sex
then do;
  age_min = 9999; * initialize to absurdly high value;
end;
age_min = min(age_min,age); * the core of calculating the minimum;
if last.sex then output; * you got that right;
keep sex age_min; * other variables are not needed in the output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For calculating an average, you will want to retain a sum and a counter, and do the calculation in a do-end block at last.sex that also contains the output statement.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 14:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426106#M104972</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-09T14:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: beginner needs help with min/max function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426111#M104974</link>
      <description>&lt;P&gt;Its quite the faff, but:&lt;/P&gt;
&lt;PRE&gt;proc sort data=sashelp.class out=class;
  by sex;
run;

data durchschnitt2 (keep=sex age_min--height_mean);
  set class;
  by sex;
  array results{3,4} age_min age_max age_count age_mean 
                     weight_min weight_max weight_count weight_mean
                     height_min height_max height_count height_mean;
  array vals{3} age weight height;
  retain age_min--height_mean;
  if first.sex then call missing(of results{*});
  do i=1 to 3;
    results{i,1}=min(results{i,1},vals{i});
    results{i,2}=max(results{i,2},vals{i});
    results{i,3}=sum(results{i,3},1);
    results{i,4}=sum(results{i,4},vals{i});
  end;
  if last.sex then do;
    do i=1 to 3;
      results{i,4}=results{i,4} / results{i,3};
    end;
    output;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Also note the use of the code window (its the {i} above post area)&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 14:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/beginner-needs-help-with-min-max-function/m-p/426111#M104974</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-09T14:33:19Z</dc:date>
    </item>
  </channel>
</rss>

