<?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: ColMin in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755759#M238547</link>
    <description>&lt;P&gt;It depends on what you're doing in the next steps as to the best method to calculate aggregate statistics.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an examples of how to add an average value to a data set, similar processes are available for other aggregate statistics.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
******************************************************;
*Add average value to a dataset;
*Solution 1 - PROC MEANS + Data step;
******************************************************;

proc means data=sashelp.class noprint;
    output out=avg_values mean(height)=avg_height;
run;

data class_data;
    set sashelp.class;

    if _n_=1 then
        set avg_values;
run;

proc print data=class;
run;

*Solution 2 - PROC SQL - note the warning in the log;
PROC SQL;
Create table class_sql as
select *, mean(height) as avg_height
from sashelp.class;
quit;

******************************************************;
*Add average value to a dataset - with grouping variables;
*Solution 1 - PROC MEANS + Data step;
******************************************************;
proc means data=sashelp.class noprint nway;
class sex;
    output out=avg_values mean(height)=avg_height;
run;

*sort data before merge;
proc sort data=sashelp.class out=class;
by sex;
run;

data class_data;
 merge class avg_values;
 by sex;


run;

proc print data=class_data;
run;

*Solution 2 - PROC SQL - note the warning in the log;
PROC SQL;
Create table class_sql as
select *, mean(height) as avg_height
from sashelp.class
group by sex;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311117"&gt;@sasuser_sk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi I use ColMin function in Brio which&amp;nbsp;&lt;SPAN&gt;returns the smallest value in a column of numbers. EX:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ColMin(Date,ID). Can someone help me find the same function in SAS or SAS EG. Thank you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;OUTPUT is:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;ID Date ColMin&lt;BR /&gt;710 2/28/2021 2/28/2021&lt;BR /&gt;7111 2/28/2021 5/27/2020&lt;BR /&gt;7111 5/27/2020 5/27/2020&lt;BR /&gt;7119 2/28/2021 1/19/2021&lt;BR /&gt;7119 1/19/2021 1/19/2021&lt;BR /&gt;7121 2/26/2021 2/26/2021&lt;BR /&gt;7121 5/31/2021 2/26/2021&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jul 2021 21:42:46 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-07-21T21:42:46Z</dc:date>
    <item>
      <title>ColMin in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755755#M238545</link>
      <description>&lt;P&gt;Hi I use ColMin function in Brio which&amp;nbsp;&lt;SPAN&gt;returns the smallest value in a column of numbers. EX:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ColMin(Date,ID). Can someone help me find the same function in SAS or SAS EG. Thank you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;OUTPUT is:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;ID Date ColMin&lt;BR /&gt;710 2/28/2021 2/28/2021&lt;BR /&gt;7111 2/28/2021 5/27/2020&lt;BR /&gt;7111 5/27/2020 5/27/2020&lt;BR /&gt;7119 2/28/2021 1/19/2021&lt;BR /&gt;7119 1/19/2021 1/19/2021&lt;BR /&gt;7121 2/26/2021 2/26/2021&lt;BR /&gt;7121 5/31/2021 2/26/2021&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 21:21:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755755#M238545</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-07-21T21:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: ColMin in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755756#M238546</link>
      <description>&lt;P&gt;What is the INPUT that produces that output?&lt;BR /&gt;You might want to use PROC SQL and the MIN() aggregate function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select id,date,min(date) as mindate format=mmddyy10.
 from have
 group by id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jul 2021 21:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755756#M238546</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-21T21:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: ColMin in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755759#M238547</link>
      <description>&lt;P&gt;It depends on what you're doing in the next steps as to the best method to calculate aggregate statistics.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an examples of how to add an average value to a data set, similar processes are available for other aggregate statistics.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
******************************************************;
*Add average value to a dataset;
*Solution 1 - PROC MEANS + Data step;
******************************************************;

proc means data=sashelp.class noprint;
    output out=avg_values mean(height)=avg_height;
run;

data class_data;
    set sashelp.class;

    if _n_=1 then
        set avg_values;
run;

proc print data=class;
run;

*Solution 2 - PROC SQL - note the warning in the log;
PROC SQL;
Create table class_sql as
select *, mean(height) as avg_height
from sashelp.class;
quit;

******************************************************;
*Add average value to a dataset - with grouping variables;
*Solution 1 - PROC MEANS + Data step;
******************************************************;
proc means data=sashelp.class noprint nway;
class sex;
    output out=avg_values mean(height)=avg_height;
run;

*sort data before merge;
proc sort data=sashelp.class out=class;
by sex;
run;

data class_data;
 merge class avg_values;
 by sex;


run;

proc print data=class_data;
run;

*Solution 2 - PROC SQL - note the warning in the log;
PROC SQL;
Create table class_sql as
select *, mean(height) as avg_height
from sashelp.class
group by sex;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311117"&gt;@sasuser_sk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi I use ColMin function in Brio which&amp;nbsp;&lt;SPAN&gt;returns the smallest value in a column of numbers. EX:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ColMin(Date,ID). Can someone help me find the same function in SAS or SAS EG. Thank you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;OUTPUT is:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;ID Date ColMin&lt;BR /&gt;710 2/28/2021 2/28/2021&lt;BR /&gt;7111 2/28/2021 5/27/2020&lt;BR /&gt;7111 5/27/2020 5/27/2020&lt;BR /&gt;7119 2/28/2021 1/19/2021&lt;BR /&gt;7119 1/19/2021 1/19/2021&lt;BR /&gt;7121 2/26/2021 2/26/2021&lt;BR /&gt;7121 5/31/2021 2/26/2021&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 21:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755759#M238547</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-21T21:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: ColMin in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755760#M238548</link>
      <description>&lt;P&gt;Thanks it worked!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 21:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755760#M238548</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-07-21T21:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: ColMin in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755762#M238550</link>
      <description>&lt;P&gt;Thank you Reeza. I will be needing these steps when I proceed further in my project.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 21:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755762#M238550</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-07-21T21:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: ColMin in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755763#M238551</link>
      <description>&lt;P&gt;Note that in general if you want to calculate statistics, like MIN, use one of the SAS procedures designed to do that.&amp;nbsp; PROC MEANS, PROC UNIVARIATE, PROC FREQ, etc.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 21:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ColMin-in-SAS/m-p/755763#M238551</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-21T21:47:45Z</dc:date>
    </item>
  </channel>
</rss>

