<?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: summary stats for many vars in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968401#M376556</link>
    <description>&lt;P&gt;I&amp;nbsp; dont understand , In my code I used&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;format=percent8.5&lt;/LI-CODE&gt;
&lt;P&gt;What do you recommend me to change here?&lt;/P&gt;
&lt;P&gt;Do you recommend me use percent8.5 or percentn8.5?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length format $50.;
length var $50.;
format='percentn8.5'; var=put(0.10412456435, percentn8.5); output;
format='percent8.5'; var=put(0.10412456435, percent8.5); output;
format='percentn8.5'; var=put(-0.10412456435, percentn8.5); output;
format='percent8.5'; var=put(-0.10412456435, percent8.5); output;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 08 Jun 2025 19:43:53 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2025-06-08T19:43:53Z</dc:date>
    <item>
      <title>summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968386#M376547</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Lets say that I want to run statistics on multiple variables.&lt;/P&gt;
&lt;P&gt;Lets say that this code is working 100% and I get desired results.&lt;/P&gt;
&lt;P&gt;My question-&lt;/P&gt;
&lt;P&gt;Is there better way to write the code (using proc step instead of proc sql)?&lt;/P&gt;
&lt;P&gt;Please note that in real word I run it on 300 fields and data set has 2 million rows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro dist(VAR,tbl,level,format);
%do j=1 %to 6;
%let version=%scan(&amp;amp;Vector_Versions.,&amp;amp;j.,+);

proc sql;
create table _dist_ as
select Left("&amp;amp;VAR.") as Var_name  LENGTH=300,
        put(&amp;amp;VAR.,&amp;amp;Format.) as Cat LENGTH=100,
		        count(*) as nr,
				calculated nr/(select count(*) as total_nr from  &amp;amp;tbl.) as PCT format=percent8.5
from &amp;amp;tbl.
group by  calculated CAT
union all
select  Left("&amp;amp;VAR.") as Var_name  LENGTH=300,
         'Total'  as CAT,
		 count(*) as nr,
		 1 as PCT format=percent8.5
from  &amp;amp;tbl.
;
quit;

proc sort data=_dist_;
by var_name level cat_order;
Run;

proc append data=_dist_ base=r_r.Accum_tbl force;quit;
%end;
%mend dist;
%dist(Var=Wealth,tbl=Y_ttt&amp;amp;version.,level=Y,Format=Fmt_1F.)
%dist(Var=LoansBalance ,tbl=Y_ttt&amp;amp;version.,level=Y,Format=Fmt_continuous.)
%dist(Var=AVG_PAYOFF_LAST_MON,tbl=Y_ttt&amp;amp;version.,level=Y,Format=Fmt_1F.)
%dist(Var=HIYUV_EXLISCAR_AMT,tbl=L_ttt&amp;amp;version.,level=L,Format=Fmt_1F.)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro dist(VAR,tbl,level,format);
%do j=1 %to 6;
%let version=%scan(&amp;amp;Vector_Versions.,&amp;amp;j.,+);

proc sql;
create table _dist_ as
select Left("&amp;amp;VAR.") as Var_name  LENGTH=300,
        put(&amp;amp;VAR.,&amp;amp;Format.) as Cat LENGTH=100,
		        count(*) as nr,
				calculated nr/(select count(*) as total_nr from  &amp;amp;tbl.) as PCT format=percent8.5
from &amp;amp;tbl.
group by  calculated CAT
union all
select  Left("&amp;amp;VAR.") as Var_name  LENGTH=300,
         'Total'  as CAT,
		 count(*) as nr,
		 1 as PCT format=percent8.5
from  &amp;amp;tbl.
;
quit;

proc sort data=_dist_;
by var_name level cat_order;
Run;

proc append data=_dist_ base=r_r.Accum_tbl force;quit;
%end;
%mend dist;
%dist(Var=Wealth,tbl=Y_ttt&amp;amp;version.,level=Y,Format=Fmt_1F.)
%dist(Var=LoansBalance ,tbl=Y_ttt&amp;amp;version.,level=Y,Format=Fmt_continuous.)
%dist(Var=AVG_PAYOFF_LAST_MON,tbl=Y_ttt&amp;amp;version.,level=Y,Format=Fmt_1F.)
%dist(Var=HIYUV_EXLISCAR_AMT,tbl=L_ttt&amp;amp;version.,level=L,Format=Fmt_1F.)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jun 2025 10:46:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968386#M376547</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-06-08T10:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968394#M376549</link>
      <description>&lt;P&gt;Here are two different ways using PROC SUMMARY or PROC FREQ to gather all of the counts you need in one pass through the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's use SASHELP.CLASS as our example dataset and get the counts for AGE and SEX variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let varlist=age sex;

proc summary data=sashelp.class chartype ;
  class &amp;amp;varlist. / missing;
  types () &amp;amp;varlist. ;
  output out=summary;
run;

proc print data=summary;
run;

ods select none;
ods output onewayfreqs=freq;
proc freq data=sashelp.class ;
  tables &amp;amp;varlist. / missing ;
run;
ods select all;

proc print data=freq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1749387806366.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107684i6386CD164791BFD8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1749387806366.png" alt="Tom_0-1749387806366.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_1-1749387828656.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107685i9010BDB2446561CD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_1-1749387828656.png" alt="Tom_1-1749387828656.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You could then add a data step to collapse the multiple columns into one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example for the PROC SUMMARY output you could do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _dist_;
  attrib Var_name  length=$300;
  attrib Cat length=$100;
	attrib nr length=8;
  attrib PCT length=8 format=percent8.5 ;
  set summary ;
  var_name=scan("Total &amp;amp;varlist",1+indexc(_type_,'1'),' ');
  Cat = vvaluex(var_name);
  nr = _freq_;
  retain Total;
  if var_name='Total' then total=_freq_;
  pct = nr / total;
  keep Var_name -- PCT;
run;

proc print data=_dist_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_2-1749388934335.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107686i1ECDE6277B2E6800/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_2-1749388934335.png" alt="Tom_2-1749388934335.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And for the PROC FREQ output something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _dist_;
  attrib Var_name  length=$300;
  attrib Cat length=$100;
	attrib nr length=8;
  attrib PCT length=8 format=percent8.5 ;
  set freq end=eof;
  var_name=substr(Table,7);
  Cat = vvaluex(cat('F_',var_name));
  nr = frequency;
  pct = percent/100;
  output;
  if eof then do;
    var_name='Total';
    cat=' ';
    nr=cumfrequency;
    pct=cumpercent/100;
    output;
  end;
  keep Var_name -- PCT;
run;

proc print data=_dist_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_3-1749389298112.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107687i08AA71E66E3B0DEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_3-1749389298112.png" alt="Tom_3-1749389298112.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: Notice that PERCENT8.3 is too short to consistently display 3 decimal places.&amp;nbsp; You forgot to leave space for ( ) that PERCENT format adds around negative values.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jun 2025 13:33:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968394#M376549</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-08T13:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968395#M376550</link>
      <description>The question is- about running time?&lt;BR /&gt;Which way do you think is lowest running time? Should have significant difference in run time?is proc sql have the history running time??</description>
      <pubDate>Sun, 08 Jun 2025 16:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968395#M376550</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-06-08T16:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968396#M376551</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The question is- about running time?&lt;BR /&gt;Which way do you think is lowest running time? Should have significant difference in run time?is proc sql have the history running time??&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Two points to consider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The PROCs I mentions should be able process ALL of the variables of interest in one pass thru the dataset.&amp;nbsp; Your method re-reads the dataset once for each variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS procs have been optimized for performance.&amp;nbsp; It might be very hard for you to write code that is as efficient.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jun 2025 17:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968396#M376551</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-08T17:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968397#M376552</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The question is- about running time?&lt;BR /&gt;Which way do you think is lowest running time? Should have significant difference in run time?is proc sql have the history running time??&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Once again, Maxim 4: Try It.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;'s single step approach&amp;nbsp;&lt;U&gt;must&lt;/U&gt; be faster than your 300 SQL steps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jun 2025 18:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968397#M376552</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-06-08T18:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968398#M376553</link>
      <description>Please note thst in grouping I used different user defined formats .Did Tom used it?</description>
      <pubDate>Sun, 08 Jun 2025 18:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968398#M376553</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-06-08T18:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968399#M376554</link>
      <description>&lt;P&gt;So your question is: will the procedures use the formatted values for grouping?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a small example dataset and test this.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jun 2025 19:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968399#M376554</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-06-08T19:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968400#M376555</link>
      <description>&lt;P&gt;My question if better to group in data step and then used the grouped vars in summary proc?&lt;/P&gt;
&lt;P&gt;or use the user defined formats on 300 variables in summary proc?&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jun 2025 19:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968400#M376555</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-06-08T19:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968401#M376556</link>
      <description>&lt;P&gt;I&amp;nbsp; dont understand , In my code I used&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;format=percent8.5&lt;/LI-CODE&gt;
&lt;P&gt;What do you recommend me to change here?&lt;/P&gt;
&lt;P&gt;Do you recommend me use percent8.5 or percentn8.5?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length format $50.;
length var $50.;
format='percentn8.5'; var=put(0.10412456435, percentn8.5); output;
format='percent8.5'; var=put(0.10412456435, percent8.5); output;
format='percentn8.5'; var=put(-0.10412456435, percentn8.5); output;
format='percent8.5'; var=put(-0.10412456435, percent8.5); output;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Jun 2025 19:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968401#M376556</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-06-08T19:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968410#M376560</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I&amp;nbsp; dont understand , In my code I used&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;format=percent8.5&lt;/LI-CODE&gt;
&lt;P&gt;What do you recommend me to change here?&lt;/P&gt;
&lt;P&gt;Do you recommend me use percent8.5 or percentn8.5?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length format $50.;
length var $50.;
format='percentn8.5'; var=put(0.10412456435, percentn8.5); output;
format='percent8.5'; var=put(0.10412456435, percent8.5); output;
format='percentn8.5'; var=put(-0.10412456435, percentn8.5); output;
format='percent8.5'; var=put(-0.10412456435, percent8.5); output;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The WIDTH value of the format specification is the total number of character.&amp;nbsp; The DECIMAL value is the number of characters after the decimal place.&amp;nbsp; &amp;nbsp;The PERCENT format needs 2 character for the optional parentheses, one for the required % and one for the optional (depending on if decimal places are requested) decimal point.&amp;nbsp; The percentages in your example program could range between 100% and 0%.&amp;nbsp; So you need three digits to the left of the decimal place.&amp;nbsp; That means you need a width of 12 to be able to have room for 5 decimal places.&amp;nbsp; 4 + 5 + 3 = 12.&lt;/P&gt;
&lt;PRE&gt;534  data _null_;
535    do p=1,.1,.01,.001,.0001,.00001;
536       put p best12. +1 p percent8.5 +1 p percent12.5;
537    end;
538  run;

           1  100.0%   100.00000%
         0.1  10.00%    10.00000%
        0.01  1.000%     1.00000%
       0.001  .1000%     0.10000%
      0.0001  .0100%     0.01000%
     0.00001  .0010%     0.00100%
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 02:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968410#M376560</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-09T02:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968411#M376561</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Please note thst in grouping I used different user defined formats .Did Tom used it?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you need to attach formats to the variables that are different than the ones that are permanently attached to them in the dataset then you can add a FORMAT statement to the PROC step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value age low-12 = '12 and under'
          13-high = '13 and over'
;
value $sex 'M'='Male' 'F'='Female';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1749436512740.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107691i2F11BE34B09C263A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1749436512740.png" alt="Tom_0-1749436512740.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_1-1749436545708.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107692i77CFF36DC21DD6A9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_1-1749436545708.png" alt="Tom_1-1749436545708.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 02:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968411#M376561</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-09T02:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968421#M376564</link>
      <description>&lt;P&gt;so i need format percent12.5?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jun 2025 06:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968421#M376564</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-06-09T06:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968527#M376599</link>
      <description>&lt;P&gt;If you add the MLF option to the CLASS statement SAS will convert numeric variables (AGE) to character variables.&amp;nbsp; &amp;nbsp;This makes it easier to work with &amp;amp;VARLIST in the OUTPUT data.&amp;nbsp; &amp;nbsp;Can even make ARRAY _V &amp;amp;VARLIST;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, DESCENDTYPES will output data in VARLIST order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=sashelp.class chartype DESCENDTYPES;
  class &amp;amp;varlist. / missing MLF;
  types () &amp;amp;varlist. ;
  output out=summary;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 14:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968527#M376599</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2025-06-10T14:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968534#M376601</link>
      <description>&lt;P&gt;One small correction: the option is MLF (short for multilabel format).&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 13:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968534#M376601</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2025-06-10T13:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968794#M376640</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The question is- about running time?&lt;BR /&gt;Which way do you think is lowest running time? Should have significant difference in run time?is proc sql have the history running time??&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In general Proc Freq and Summary are both more efficient than Proc SQL. In&amp;nbsp; many cases faster by order(s) of magnitude. Reloading the data set multiple times alone for each variable would take many times the execution of the other procedures. Since you want percentages and no other procedures than counts then Proc Freq is almost certainly the fastest solution UNLESS you are using multiple grouping variables in multiple combinations i.e. a count by region, polity, sex, ; region and sex; polity and sex. Doing multiples of these might make Proc Summary preferred as the default counting tool.&lt;/P&gt;
&lt;P&gt;Consider:&lt;/P&gt;
&lt;PRE&gt;proc summary data=sashelp.cars;
   class  make  type origin drivetrain enginesize cylinders;
   output out=work.carsummary ;
run; &lt;/PRE&gt;
&lt;P&gt;If you look at the _type_ = 1 then _freq_ is total number of observations in the data set with the given number of cylinders in the data. _type_=3 then _freq_ is the number of cylinders for the given Engine size. _type_=5 is the number cylinders given the drive train. _type_=11 is the number of cylinders of the engine for engine size for given value of Origin.&amp;nbsp; Many combinations represented and can be selected by _type_. And custom format for the _TYPE_ variable could make a very useful report tool. The order of variables on the CLASS statement determines the values of the combinations so if the Class statement is changed any dependencies of _type_ have to be considered for selection or reporting.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Different formats applied to different variables will not have an issue with Proc Freq or Summary. If you are using different grouping formats for the&amp;nbsp;&lt;STRONG&gt;same&lt;/STRONG&gt; variable that would likely be an issue. Since you don't show any of the custom formats you use in the code we really can't tell what the effects might be.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2025 20:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968794#M376640</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-06-11T20:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: summary stats for many vars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968837#M376650</link>
      <description>&lt;P&gt;If you want the summary output as a data set, you will also want to look into the Proc MEANS option STACKODSOUTPUT.&lt;/P&gt;
&lt;P&gt;You are summarizing data in different data sets (tbl=Y_TTT*|L_TTT*) you will need, at a minimum, one use of Proc MEANS per table.&lt;/P&gt;
&lt;P&gt;If the variables being summarized in the separate table are exclusive to a table, you probably want to stick to one MEANS per table. However, when producing output data for a wide audience, you would be well served to have the source data set name in the summary results.&lt;/P&gt;
&lt;P&gt;If the data set structures are similar enough in 'identity of measure (i.e. customer id and region)' and the measure are in different data sets, perhaps due to policy of splitting data by year or month, you can stack the data sets and use one Proc MEANS on the stack.&amp;nbsp; If you are stacking data sets it is good practice to incorporate the source data set name in the summary results if you need that temporality as a categorical variable.&amp;nbsp; The stacking can be a delivered through a view.&lt;/P&gt;
&lt;P&gt;With the proper hardware 2m x 100 summarization will happen quickly.&lt;/P&gt;
&lt;DIV id="b_mrs_DynamicMRS" class="b_mrs"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;ASIDE class="" aria-label="Additional Results"&gt;&lt;/ASIDE&gt;</description>
      <pubDate>Thu, 12 Jun 2025 12:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/summary-stats-for-many-vars/m-p/968837#M376650</guid>
      <dc:creator>RichardAD</dc:creator>
      <dc:date>2025-06-12T12:27:12Z</dc:date>
    </item>
  </channel>
</rss>

