<?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: add statistics to proc freq output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866353#M342122</link>
    <description>&lt;P&gt;You definitely want to use PROC REPORT for this !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL class="lia-list-style-type-square"&gt;
&lt;LI&gt;Paper 3582-2019&lt;BR /&gt;SuperFreq: Using the REPORT Procedure to Create Multi-Level Frequency Tables&lt;BR /&gt;Jedediah J Teres, MDRC&lt;BR /&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings19/3582-2019.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings19/3582-2019.pdf&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Getting Freqy with PROC REPORT&lt;BR /&gt;Ethan Miller, SRI International, Menlo Park, Ca&lt;BR /&gt;&lt;A href="https://www.lexjansen.com/wuss/2011/tut/Papers_Miller_E_76116.pdf" target="_blank"&gt;https://www.lexjansen.com/wuss/2011/tut/Papers_Miller_E_76116.pdf&lt;/A&gt;&lt;BR /&gt;This paper will illustrate how to produce frequencies, cross tabulations, and means using PROC REPORT, and show various style options that can be used with ODS.&lt;/LI&gt;
&lt;LI&gt;Paper AA700 -- Where Proc FREQ ends and Proc REPORT begins&lt;BR /&gt;Thushan Wijesinghe, LexisNexis, Miamisburg, OH&lt;BR /&gt;&lt;A href="https://www.lexjansen.com/mwsug/2005/Application_Development/AA700.pdf" target="_blank"&gt;https://www.lexjansen.com/mwsug/2005/Application_Development/AA700.pdf&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Koen&lt;/P&gt;
&lt;DIV id="ConnectiveDocSignExtentionInstalled" data-extension-version="1.0.4"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Sun, 26 Mar 2023 08:28:27 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2023-03-26T08:28:27Z</dc:date>
    <item>
      <title>add statistics to proc freq output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866312#M342110</link>
      <description>&lt;P&gt;Simple question, here is code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data status;&lt;BR /&gt;input lines_group $ rows_group $ value proportion;&lt;BR /&gt;datalines;&lt;BR /&gt;0$-15$ 0%-40% 10 30&lt;BR /&gt;26$-35$ 41%-60% 34 41&lt;BR /&gt;16$-25$ 41%-60% 22 51&lt;BR /&gt;26$-35$ 41%-60% 26 54&lt;BR /&gt;16$-25$ 61%-100% 17 90&lt;BR /&gt;26$-35$ 0%-40% 32 10&lt;BR /&gt;26$-35$ 61%-100% 30 78&lt;BR /&gt;26$-35$ 41%-60% 26 45&lt;BR /&gt;16$-25$ 0%-40% 22 12&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc freq order=data;&lt;BR /&gt;tables lines_group*rows_group;&lt;BR /&gt;exact or;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="marc11235_0-1679780983097.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82037i493D7487323AC0BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="marc11235_0-1679780983097.png" alt="marc11235_0-1679780983097.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For 10k observations and 10X10 classes table, is it possible to add variables "value" and "proportion" means, with which the groups are defined? It would make 6 stats by cells. Maybe with another procedure than proc freq?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, and have a great day!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2023 21:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866312#M342110</guid>
      <dc:creator>marc11235</dc:creator>
      <dc:date>2023-03-25T21:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: add statistics to proc freq output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866313#M342111</link>
      <description>&lt;P&gt;PROC MEANS !&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data status;
input lines_group $ rows_group $ value proportion;
datalines;
0$-15$  0%-40%   10 30
26$-35$ 41%-60%  34 41
16$-25$ 41%-60%  22 51
26$-35$ 41%-60%  26 54
16$-25$ 61%-100% 17 90
26$-35$ 0%-40%   32 10
26$-35$ 61%-100% 30 78
26$-35$ 41%-60%  26 45
16$-25$ 0%-40%   22 12
;
run;
proc freq order=data;
tables lines_group*rows_group;
*exact or;
run;
proc means nway completetypes;
 CLASS lines_group rows_group;
 VAR   value proportion;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2023 22:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866313#M342111</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-03-25T22:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: add statistics to proc freq output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866314#M342112</link>
      <description>&lt;P&gt;Thanks Koen for the fast answer! Problem isn't to get the stats, it is to display them... Multiple tables are by groups, my output need to be .rtf or .xlsx file ready for user in this format but 10x10 classes :&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;TABLE border="1" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Rows_group&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Lines_group&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Frequency&lt;/P&gt;&lt;P&gt;Percent&lt;/P&gt;&lt;P&gt;Row percent&lt;/P&gt;&lt;P&gt;Col percent&lt;/P&gt;&lt;P&gt;Value mean&lt;/P&gt;&lt;P&gt;Proportion mean&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;I was thinking to build 'manually' the table and display results with proc report or proc tabulate but it was getting tricky, I ended thinking it wasn't the good approach. Proc freq gives me most important stats user need, but I been asked if I can add means of variables which created the classes. and I like to please users who have good use of stats!!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm still trying to find an idea but I'm stuck in circular reasoning and worse case it will end in 2 separate tables but it wouldn't be nice and finished job...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Marc&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 25 Mar 2023 23:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866314#M342112</guid>
      <dc:creator>marc11235</dc:creator>
      <dc:date>2023-03-25T23:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: add statistics to proc freq output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866353#M342122</link>
      <description>&lt;P&gt;You definitely want to use PROC REPORT for this !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL class="lia-list-style-type-square"&gt;
&lt;LI&gt;Paper 3582-2019&lt;BR /&gt;SuperFreq: Using the REPORT Procedure to Create Multi-Level Frequency Tables&lt;BR /&gt;Jedediah J Teres, MDRC&lt;BR /&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings19/3582-2019.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings19/3582-2019.pdf&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Getting Freqy with PROC REPORT&lt;BR /&gt;Ethan Miller, SRI International, Menlo Park, Ca&lt;BR /&gt;&lt;A href="https://www.lexjansen.com/wuss/2011/tut/Papers_Miller_E_76116.pdf" target="_blank"&gt;https://www.lexjansen.com/wuss/2011/tut/Papers_Miller_E_76116.pdf&lt;/A&gt;&lt;BR /&gt;This paper will illustrate how to produce frequencies, cross tabulations, and means using PROC REPORT, and show various style options that can be used with ODS.&lt;/LI&gt;
&lt;LI&gt;Paper AA700 -- Where Proc FREQ ends and Proc REPORT begins&lt;BR /&gt;Thushan Wijesinghe, LexisNexis, Miamisburg, OH&lt;BR /&gt;&lt;A href="https://www.lexjansen.com/mwsug/2005/Application_Development/AA700.pdf" target="_blank"&gt;https://www.lexjansen.com/mwsug/2005/Application_Development/AA700.pdf&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Koen&lt;/P&gt;
&lt;DIV id="ConnectiveDocSignExtentionInstalled" data-extension-version="1.0.4"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 26 Mar 2023 08:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866353#M342122</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-03-26T08:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: add statistics to proc freq output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866376#M342126</link>
      <description>&lt;P&gt;Thanks again Koen, it comforts me that intuition was good! I'm mostly using proc report to make lists, but I did know it was much more powerful... With that documentation, I have everything to customize my output as needed. I was probably trying too much to create a matrix style result and simply display it but indeed I&lt;SPAN&gt;&amp;nbsp;can put "raw" data in proc report and tell it what to do with them!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a very good day!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2023 12:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866376#M342126</guid>
      <dc:creator>marc11235</dc:creator>
      <dc:date>2023-03-26T12:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: add statistics to proc freq output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866427#M342158</link>
      <description>&lt;P&gt;Hello Koen, just to share results :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried with proc report but I wasn't able to calculate statistics by rows e.g. row proportion... I don't mind about the look of the report, I need numbers to be all within a single page ready to use. Here is what I finally obtained with proc sql and proc tabulate, it can handle any 2 dimensions table size with any kind of stats included :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data status;&lt;BR /&gt;input row_group $ col_group $ value proportion tout $;&lt;BR /&gt;datalines;&lt;BR /&gt;0$-15$ 0%-40% 10 30 all&lt;BR /&gt;26$-35$ 41%-60% 34 41 all&lt;BR /&gt;16$-25$ 41%-60% 22 51 all&lt;BR /&gt;26$-35$ 41%-60% 26 54 all&lt;BR /&gt;16$-25$ 61%-100% 17 90 all&lt;BR /&gt;26$-35$ 0%-40% 32 10 all&lt;BR /&gt;26$-35$ 61%-100% 30 78 all&lt;BR /&gt;26$-35$ 41%-60% 26 45 all&lt;BR /&gt;16$-25$ 0%-40% 22 12 all&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;/* total global */&lt;BR /&gt;proc sql;&lt;BR /&gt;create table status2 as&lt;BR /&gt;select *,&lt;BR /&gt;count(tout) as n_obs,&lt;BR /&gt;mean(value) as tot_val_mean,&lt;BR /&gt;mean(proportion) as tot_prop_mean&lt;BR /&gt;from status;&lt;BR /&gt;quit;&lt;BR /&gt;proc sort data=status2 out=tot nodupkey;&lt;BR /&gt;by tout;&lt;BR /&gt;run;&lt;BR /&gt;data tot;&lt;BR /&gt;set tot;&lt;BR /&gt;row_group="total";&lt;BR /&gt;col_group="total";&lt;BR /&gt;rename tot_val_mean=val_mean;&lt;BR /&gt;rename tot_prop_mean=prop_mean;&lt;BR /&gt;rename n_obs=freq;&lt;BR /&gt;pct=100;&lt;BR /&gt;col_pct=100;&lt;BR /&gt;row_pct=100;&lt;BR /&gt;drop value proportion tout;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/* total colonnes */&lt;BR /&gt;proc sql;&lt;BR /&gt;create table status3 as&lt;BR /&gt;select *,&lt;BR /&gt;count(tout) as col_freq,&lt;BR /&gt;100 as col_pct,&lt;BR /&gt;count(tout)/n_obs as pct,&lt;BR /&gt;100 as row_pct,&lt;BR /&gt;mean(value) as col_val_mean,&lt;BR /&gt;mean(proportion) as col_prop_mean&lt;BR /&gt;from status2&lt;BR /&gt;group by col_group;&lt;BR /&gt;quit;&lt;BR /&gt;proc sort data=status3 out=col_tot nodupkey;&lt;BR /&gt;by col_group;&lt;BR /&gt;run;&lt;BR /&gt;data col_tot;&lt;BR /&gt;set col_tot;&lt;BR /&gt;row_group="total";&lt;BR /&gt;rename col_freq=freq;&lt;BR /&gt;rename col_val_mean=val_mean;&lt;BR /&gt;rename col_prop_mean=prop_mean;&lt;BR /&gt;drop value proportion tout N_obs tot_val_mean tot_prop_mean;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/* total lignes */&lt;BR /&gt;proc sql;&lt;BR /&gt;create table status4 as&lt;BR /&gt;select *,&lt;BR /&gt;count(tout) as row_freq,&lt;BR /&gt;100 as row_pct,&lt;BR /&gt;count(tout)/n_obs as pct,&lt;BR /&gt;100 as col_pct,&lt;BR /&gt;mean(value) as row_val_mean,&lt;BR /&gt;mean(proportion) as row_prop_mean&lt;BR /&gt;from status3&lt;BR /&gt;group by row_group;&lt;BR /&gt;quit;&lt;BR /&gt;proc sort data=status4 out=row_tot nodupkey;&lt;BR /&gt;by row_group;&lt;BR /&gt;run;&lt;BR /&gt;data row_tot;&lt;BR /&gt;set row_tot;&lt;BR /&gt;col_group="total";&lt;BR /&gt;rename row_freq=freq;&lt;BR /&gt;rename row_val_mean=val_mean;&lt;BR /&gt;rename row_prop_mean=prop_mean;&lt;BR /&gt;drop value proportion tout N_obs tot_val_mean tot_prop_mean col_freq col_val_mean col_prop_mean;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/* total cellules */&lt;BR /&gt;proc sql;&lt;BR /&gt;create table status5 as&lt;BR /&gt;select col_group,&lt;BR /&gt;row_group,&lt;BR /&gt;count(tout) as cell_freq,&lt;BR /&gt;count(tout)/N_obs as pct,&lt;BR /&gt;count(tout)/col_freq as col_pct,&lt;BR /&gt;count(tout)/row_freq as row_pct,&lt;BR /&gt;mean(value) as cell_val_mean,&lt;BR /&gt;mean(proportion) as cell_prop_mean&lt;BR /&gt;from status4&lt;BR /&gt;group by col_group, row_group;&lt;BR /&gt;quit;&lt;BR /&gt;proc sort data=status5 out=cell_tot nodupkey;&lt;BR /&gt;by col_group row_group;&lt;BR /&gt;run;&lt;BR /&gt;data cell_tot;&lt;BR /&gt;set cell_tot;&lt;BR /&gt;rename cell_freq=freq;&lt;BR /&gt;rename cell_val_mean=val_mean;&lt;BR /&gt;rename cell_prop_mean=prop_mean;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data tout;&lt;BR /&gt;set cell_tot col_tot row_tot tot;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc tabulate data=tout;&lt;BR /&gt;class col_group row_group;&lt;BR /&gt;var freq pct col_pct row_pct val_mean prop_mean;&lt;BR /&gt;table row_group*(freq pct col_pct row_pct val_mean prop_mean),&lt;BR /&gt;col_group;&lt;BR /&gt;run;&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;code isn't cleaned but it works, i felt like recoding proc freq the way i would like it ahah!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again and sorry if my english isn't as good as if it would be natural to me!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 26 Mar 2023 23:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-statistics-to-proc-freq-output/m-p/866427#M342158</guid>
      <dc:creator>marc11235</dc:creator>
      <dc:date>2023-03-26T23:20:30Z</dc:date>
    </item>
  </channel>
</rss>

