<?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: Help on proc report: display frequency count and percentage within one cell in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-on-proc-report-display-frequency-count-and-percentage/m-p/579972#M23150</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; It is useful to understand what PROC REPORT will give you by default and make sure you get the right numbers and then work toward cosmetically improving the report to look like what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here are some points to remember:&lt;/P&gt;
&lt;P&gt;1) Almost all SAS procedures will only give you 1 value for cell/column. So, for example, on a report, by default, SAS will usually be able to give you a column for the N or the count and give you another column for the percent of count. But unless you create a character value that is the combination of (N/%), SAS won't put 2 values in one cell.&lt;/P&gt;
&lt;P&gt;2) If you want the count in the Header for a variable value, as you show with your N=6 or N=3, then you need to pre-calculate these values and make helper macro variables to hold the counts you need. There are several different ways to do this. I show just one way in the modified data creation program below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the modified DATA step to read the data, accumulate the totals and make helper macro variables using CALL SYMPUTX:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="count_percent_helper_vars.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31598i959CB5D7EC959BA1/image-size/large?v=v2&amp;amp;px=999" role="button" title="count_percent_helper_vars.png" alt="count_percent_helper_vars.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Using PROC REPORT, there are 3 different examples of how you might get the default counts and percents, each count and percent in its own cell:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="default_count_percent.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31599i361C51D23584707C/image-size/large?v=v2&amp;amp;px=999" role="button" title="default_count_percent.png" alt="default_count_percent.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what you have to understand first because you need to make sure you can generate the numbers you want correctly, taking the defaults before you start on finessing the cosmetics of the report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, next, you would need to understand the PROC REPORT COMPUTE block if you really need to get the (N,%) in one cell -- because you'll need to make a character column to hold the concatenated values and display the concatenated values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are several different postings in the Forums about how to make computed columns in PROC REPORT. You might want to look for those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Aug 2019 19:24:43 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2019-08-08T19:24:43Z</dc:date>
    <item>
      <title>Help on proc report: display frequency count and percentage within one cell</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-on-proc-report-display-frequency-count-and-percentage/m-p/579955#M23149</link>
      <description>&lt;P&gt;I am not a professional SAS programmer, but I am working as a statistics intern now to help producing some report.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have data like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input ID $  type1 $ type2 $;
  datalines;
  1 A1 B1
  2 A1 B2
  3 A2 B2
  4 A1 B2
  5 A2 B1
  6 A2 B1
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So we have: A1 and B1: 1 subject; A1 and B2: 2 subjects; A2 and B1: 2 subjects; A2 and B2: 1 subject&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To generate a frequency table using proc report and achieve the following lay out:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mocking_1.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31596iA846EA412E1AFDB7/image-size/large?v=v2&amp;amp;px=999" role="button" title="mocking_1.png" alt="mocking_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am very new to proc report. I have been getting basic understanding of this procedure from&amp;nbsp;&lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com&lt;/A&gt;&amp;nbsp;and I understand those examples, however none of the examples help me to get idea how to generate this exactly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice or help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 17:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-on-proc-report-display-frequency-count-and-percentage/m-p/579955#M23149</guid>
      <dc:creator>guanlinchang</dc:creator>
      <dc:date>2019-08-08T17:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help on proc report: display frequency count and percentage within one cell</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-on-proc-report-display-frequency-count-and-percentage/m-p/579972#M23150</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; It is useful to understand what PROC REPORT will give you by default and make sure you get the right numbers and then work toward cosmetically improving the report to look like what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here are some points to remember:&lt;/P&gt;
&lt;P&gt;1) Almost all SAS procedures will only give you 1 value for cell/column. So, for example, on a report, by default, SAS will usually be able to give you a column for the N or the count and give you another column for the percent of count. But unless you create a character value that is the combination of (N/%), SAS won't put 2 values in one cell.&lt;/P&gt;
&lt;P&gt;2) If you want the count in the Header for a variable value, as you show with your N=6 or N=3, then you need to pre-calculate these values and make helper macro variables to hold the counts you need. There are several different ways to do this. I show just one way in the modified data creation program below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the modified DATA step to read the data, accumulate the totals and make helper macro variables using CALL SYMPUTX:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="count_percent_helper_vars.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31598i959CB5D7EC959BA1/image-size/large?v=v2&amp;amp;px=999" role="button" title="count_percent_helper_vars.png" alt="count_percent_helper_vars.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Using PROC REPORT, there are 3 different examples of how you might get the default counts and percents, each count and percent in its own cell:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="default_count_percent.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31599i361C51D23584707C/image-size/large?v=v2&amp;amp;px=999" role="button" title="default_count_percent.png" alt="default_count_percent.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what you have to understand first because you need to make sure you can generate the numbers you want correctly, taking the defaults before you start on finessing the cosmetics of the report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, next, you would need to understand the PROC REPORT COMPUTE block if you really need to get the (N,%) in one cell -- because you'll need to make a character column to hold the concatenated values and display the concatenated values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are several different postings in the Forums about how to make computed columns in PROC REPORT. You might want to look for those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 19:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-on-proc-report-display-frequency-count-and-percentage/m-p/579972#M23150</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-08-08T19:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help on proc report: display frequency count and percentage within one cell</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-on-proc-report-display-frequency-count-and-percentage/m-p/579983#M23151</link>
      <description>&lt;P&gt;Hi, Cynthia:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is very helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate you breaking things down for me this way, and it definitely makes a lot of sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess this is a good start for me. My actual data is not provided with datalines though, it comes with the extraction form a database and is already saved into a SAS format, however I do not think this is a issue for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your swift and detailed response.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 19:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-on-proc-report-display-frequency-count-and-percentage/m-p/579983#M23151</guid>
      <dc:creator>guanlinchang</dc:creator>
      <dc:date>2019-08-08T19:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help on proc report: display frequency count and percentage within one cell</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-on-proc-report-display-frequency-count-and-percentage/m-p/579997#M23152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If you already have SAS datasets, then you can use other techniques to get your overall counts that you need -- you could use PROC FREQ, PROC MEANS, PROC SQL.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 21:07:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Help-on-proc-report-display-frequency-count-and-percentage/m-p/579997#M23152</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-08-08T21:07:46Z</dc:date>
    </item>
  </channel>
</rss>

