<?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 Identifying Extreme Values of Analysis Variables using the IDGROUP Option for many columns in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Identifying-Extreme-Values-of-Analysis-Variables-using-the/m-p/851976#M37420</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I try to identify Extreme Values of Analysis Variables but for many columns. Could you help me and explain how I can do it for many columns?&lt;/P&gt;&lt;P&gt;It's how I do it for one columns;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc means data=w2;

var act_age ;
output out=stat 
idgroup (max(act_age) out[2] (act_age)=maxrev) idgroup (min(act_age) 
out[2] (act_age)=minrev) q1=q3=mean= /autoname;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Jan 2023 14:43:11 GMT</pubDate>
    <dc:creator>Anastasija98</dc:creator>
    <dc:date>2023-01-03T14:43:11Z</dc:date>
    <item>
      <title>Identifying Extreme Values of Analysis Variables using the IDGROUP Option for many columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-Extreme-Values-of-Analysis-Variables-using-the/m-p/851976#M37420</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I try to identify Extreme Values of Analysis Variables but for many columns. Could you help me and explain how I can do it for many columns?&lt;/P&gt;&lt;P&gt;It's how I do it for one columns;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc means data=w2;

var act_age ;
output out=stat 
idgroup (max(act_age) out[2] (act_age)=maxrev) idgroup (min(act_age) 
out[2] (act_age)=minrev) q1=q3=mean= /autoname;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 14:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-Extreme-Values-of-Analysis-Variables-using-the/m-p/851976#M37420</guid>
      <dc:creator>Anastasija98</dc:creator>
      <dc:date>2023-01-03T14:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Extreme Values of Analysis Variables using the IDGROUP Option for many columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-Extreme-Values-of-Analysis-Variables-using-the/m-p/852009#M37422</link>
      <description>&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 LENGTH Name $ 5;
 set sashelp.shoes;
 Name=put(_N_,z5.);
run;

proc means data=have nway;
 CLASS Region Product;
 var Sales Inventory Returns ;
 output out=stat
 idgroup (max(Sales Inventory Returns) /*obs*/ out[3] (Sales Inventory Returns Name Region Product)=) 
 q1= q3= mean= / autolabel autoname /*levels*/;
run;

proc transpose data=stat out=stat_max_trp(rename=(col1=col1_MAX)); BY Region Product; run;

proc means data=have nway;
 CLASS Region Product;
 var Sales Inventory Returns ;
 output out=stat
 idgroup (min(Sales Inventory Returns) /*obs*/ out[3] (Sales Inventory Returns Name Region Product)=)
 q1= q3= mean= / autolabel autoname /*levels*/;
run;

proc transpose data=stat out=stat_min_trp(rename=(col1=col1_MIN)); BY Region Product; run;

data want;
 merge stat_max_trp stat_min_trp;
 *BY Region Product _NAME_ _LABEL_;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 17:56:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-Extreme-Values-of-Analysis-Variables-using-the/m-p/852009#M37422</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-01-03T17:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Extreme Values of Analysis Variables using the IDGROUP Option for many columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-Extreme-Values-of-Analysis-Variables-using-the/m-p/852011#M37423</link>
      <description>&lt;P&gt;You don't appear to be asking for any ID for the max or min values. Is that in fact the case and you just want the n max /min values?&lt;/P&gt;
&lt;P&gt;Just repeat the variable names in the positions you have your variable:&lt;/P&gt;
&lt;PRE&gt;proc means data=sashelp.class noprint;
   var height weight;

   output out=summary
   idgroup (max(height weight) out[2] (height weight)=maxh maxw) 
   idgroup (min(height weight) out[2] (height weight)=minh minw)
   ;
run;&lt;/PRE&gt;
&lt;P&gt;If there are truly "many" variables getting the names of the output variables may be entertaining&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How many max or min values do you want? Proc Univariate by default will give 5 max and min values for every variable on the VAR statement.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 18:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-Extreme-Values-of-Analysis-Variables-using-the/m-p/852011#M37423</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-03T18:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying Extreme Values of Analysis Variables using the IDGROUP Option for many columns</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identifying-Extreme-Values-of-Analysis-Variables-using-the/m-p/852013#M37424</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/425736"&gt;@Anastasija98&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My understanding is that you want to analyze several numeric variables &lt;EM&gt;separately&lt;/EM&gt;, so that specifying their names in a single variable list in the MAX(...) and MIN(...) parts of the IDGROUP specification is &lt;EM&gt;not&lt;/EM&gt; appropriate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could type two more IDGROUP specifications for each additional analysis variable. If there are too many analysis variables for this manual approach, you can use code generation, e.g., create the code of the OUTPUT statement in a DATA step and then &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p1s3uhhqtscz2sn1otiatbovfn1t.htm" target="_blank" rel="noopener"&gt;%INCLUDE&lt;/A&gt; it in the PROC MEANS step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example creating the desired statistics for all numeric variables in dataset SASHELP.CARS, arbitrarily excluding&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;E&lt;/STRONG&gt;ngineSize&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;C&lt;/STRONG&gt;ylinders&lt;/FONT&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename outpstmt temp;

data _null_;
file outpstmt;
set sashelp.vcolumn end=last;
where libname='SASHELP' &amp;amp; memname='CARS' &amp;amp; type='num' &amp;amp; name ~in: ('E','C');
if _n_=1 then put 'output out=stat';
put 'idgroup (max(' name +(-1) ') out[2] (' name +(-1) ')=' name +(-1) '_Max)';
put 'idgroup (min(' name +(-1) ') out[2] (' name +(-1) ')=' name +(-1) '_Min)';
if last then put 'q1= q3= mean= /autoname;';
run;

proc means data=sashelp.cars(drop=e: c:);
var _numeric_;
%include outpstmt / source2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above DATA step writes the complete OUTPUT statement including sixteen similar IDGROUP specifications (two for each of the eight variables &lt;FONT face="courier new,courier"&gt;MSRP&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;Invoice&lt;/FONT&gt;, ..., &lt;FONT face="courier new,courier"&gt;Length&lt;/FONT&gt;) to a temporary text file, which the %INCLUDE statement then refers to in the PROC MEANS step (see the part of the log created by the SOURCE2 option). The eight variable names are retrieved from the view SASHELP.VCOLUMN. The WHERE condition in your application may start with&lt;/P&gt;
&lt;PRE&gt;libname='WORK' &amp;amp; memname='W2'&lt;/PRE&gt;
&lt;P&gt;(note the upper-case strings) and possibly omit the criterion (using variable &lt;FONT face="courier new,courier"&gt;name&lt;/FONT&gt;) restricting the set of analysis variables or use a different criterion to select the appropriate set of variable names. Similarly, the DROP= dataset option in the PROC MEANS step would be omitted, modified or replaced by a KEEP= dataset option (or a more specific VAR statement).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the two PUT statements I specified that the names of the variables containing the extreme values be constructed as, e.g., &lt;FONT face="courier new,courier"&gt;MSRP_Max_1&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;MSRP_Max_2&lt;/FONT&gt;,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;MSRP_Min_1&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;MSRP_Min_2&lt;/FONT&gt; (for analysis variable &lt;FONT face="courier new,courier"&gt;MSRP&lt;/FONT&gt;), to be consistent with the variable names for the quartiles and the means created by the AUTONAME option.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 18:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identifying-Extreme-Values-of-Analysis-Variables-using-the/m-p/852013#M37424</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-01-03T18:36:51Z</dc:date>
    </item>
  </channel>
</rss>

