<?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: Proc Tabulate- Counts and Percentages within a Single Cell in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664086#M198353</link>
    <description>There's this one but it's definitely overkill for what OP is doing. &lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;A quick PROC FREQ and REPORT is easier. &lt;BR /&gt;&lt;BR /&gt;The code here does something similar as well. &lt;BR /&gt;&lt;A href="https://gist.github.com/statgeek/0c4aeec9053cf8050be18a03b842c1b9" target="_blank"&gt;https://gist.github.com/statgeek/0c4aeec9053cf8050be18a03b842c1b9&lt;/A&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 22 Jun 2020 22:39:57 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-06-22T22:39:57Z</dc:date>
    <item>
      <title>Proc Tabulate- Counts and Percentages within a Single Cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664056#M198339</link>
      <description>&lt;P&gt;I currently generating a report using some descriptive statistics within Proc Tabulate where I generate the counts and percentages to produce an Excel output using ODS. Originally, I would produce a single cell for each value generated from Proc Tabulate, but I've received a request to combine the values into a single cell within the Excel output. For example, the output would contain n (%) within one cell.&amp;nbsp;The data structure contains a record for each id with a designated cohort flag to identify the respected group. I've found that you can add the parentheses around the percentages using Proc Format along with the "prefix" option, but I'm having issues figuring out if it is possible to combine the two cells while maintaining an Excel output.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I realize it isn't ideal to have two values within a single Excel sheet, but the original program incorporates Proc Tabulate to generate the&amp;nbsp;statistics for the outputs and I would like to avoid running it in Proc Report if possible.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an example of the current output:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Overall&lt;/TD&gt;&lt;TD&gt;Disease 1&lt;/TD&gt;&lt;TD&gt;Disease 2&lt;/TD&gt;&lt;TD&gt;Disease 3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;N (count)&lt;/TD&gt;&lt;TD&gt;3,000&lt;/TD&gt;&lt;TD&gt;1,000&lt;/TD&gt;&lt;TD&gt;1,500&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Male&lt;/TD&gt;&lt;TD&gt;1,350&lt;/TD&gt;&lt;TD&gt;450&lt;/TD&gt;&lt;TD&gt;675&lt;/TD&gt;&lt;TD&gt;225&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;%&lt;/TD&gt;&lt;TD&gt;45.00%&lt;/TD&gt;&lt;TD&gt;45.00%&lt;/TD&gt;&lt;TD&gt;45.00%&lt;/TD&gt;&lt;TD&gt;45.00%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Female&lt;/TD&gt;&lt;TD&gt;1,650&lt;/TD&gt;&lt;TD&gt;650&lt;/TD&gt;&lt;TD&gt;825&lt;/TD&gt;&lt;TD&gt;275&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;%&lt;/TD&gt;&lt;TD&gt;55.00%&lt;/TD&gt;&lt;TD&gt;55.00%&lt;/TD&gt;&lt;TD&gt;55.00%&lt;/TD&gt;&lt;TD&gt;55.00%&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an example of the desired output:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Overall&lt;/TD&gt;&lt;TD&gt;Disease 1&lt;/TD&gt;&lt;TD&gt;Disease 2&lt;/TD&gt;&lt;TD&gt;Disease 3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;N (count)&lt;/TD&gt;&lt;TD&gt;3,000&lt;/TD&gt;&lt;TD&gt;1,000&lt;/TD&gt;&lt;TD&gt;1,500&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Male&amp;nbsp;N (%)&lt;/TD&gt;&lt;TD&gt;1,350 (45.00%)&lt;/TD&gt;&lt;TD&gt;450 (45.00%)&lt;/TD&gt;&lt;TD&gt;675&amp;nbsp;(45.00%)&lt;/TD&gt;&lt;TD&gt;225&amp;nbsp;(45.00%)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Female&amp;nbsp;N (%)&lt;/TD&gt;&lt;TD&gt;1,650 (55.00%)&lt;/TD&gt;&lt;TD&gt;650 (55.00%)&lt;/TD&gt;&lt;TD&gt;825 (55.00%)&lt;/TD&gt;&lt;TD&gt;275 (55.00%)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 22 Jun 2020 19:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664056#M198339</guid>
      <dc:creator>Macromore</dc:creator>
      <dc:date>2020-06-22T19:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Tabulate- Counts and Percentages within a Single Cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664076#M198346</link>
      <description>How about combining fields outside proc tabulate? Some of report requests are based on visual appeal and convenience but make little sense while programming. Format both values, combine as text fields and then use tabulate.</description>
      <pubDate>Mon, 22 Jun 2020 21:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664076#M198346</guid>
      <dc:creator>Nihanta</dc:creator>
      <dc:date>2020-06-22T21:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Tabulate- Counts and Percentages within a Single Cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664077#M198347</link>
      <description>AFAIK that can't be done. You need to use PROC REPORT or PRINT because it's now a character field, not a summarized and dynamic field. Or you could play around with modifying the template but that's not easy and I don't know if it's technically even possible.</description>
      <pubDate>Mon, 22 Jun 2020 22:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664077#M198347</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-22T22:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Tabulate- Counts and Percentages within a Single Cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664085#M198352</link>
      <description>&lt;P&gt;Define&amp;nbsp; "in a single cell"?&lt;/P&gt;
&lt;P&gt;Does it have to be a cell that excel recognizes or just appear that way?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tabulate will only create a single value in any any cell though a format might make it appear to be two values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
picture myfakepct  
low-high = '009.99%)' (prefix='(');
run;
proc tabulate data = sashelp.class;
   class sex age;
   table sex,
         age*(n=' '*[style=[just=r borderrightwidth=0]] 
              pctn=' '*[style=[borderleftwidth=0 just=l]]*f=myfakepct.
             )
         / misstext=' '
   ;
run;&lt;/PRE&gt;
&lt;P&gt;You did not provide any example code for how you currently created percent values or applied a format.&lt;/P&gt;
&lt;P&gt;The values of the PCTN format are actually a fw.d type format so you would need to fake a % sign if desired. The custom format fakes that for this data.&lt;/P&gt;
&lt;P&gt;The style elements borderleftwidth and borderrightwidth set to 0 will suppress a local vertical border when applied to the correct sides of the cell, the Just= option moves the N and Pctn values closer to each each other.&lt;/P&gt;
&lt;P&gt;A side affect of this approach is that the N will be above one another with typical alignment of the lowest signficance digit. If you create a single character value alignment might become more interesting and unless you are using a format Tabulated won't show them in the body of the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is also&amp;nbsp; "demographics report" macro floating around this site that I don't have bookmarked that may be of more interest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 22:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664085#M198352</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-22T22:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Tabulate- Counts and Percentages within a Single Cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664086#M198353</link>
      <description>There's this one but it's definitely overkill for what OP is doing. &lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;A quick PROC FREQ and REPORT is easier. &lt;BR /&gt;&lt;BR /&gt;The code here does something similar as well. &lt;BR /&gt;&lt;A href="https://gist.github.com/statgeek/0c4aeec9053cf8050be18a03b842c1b9" target="_blank"&gt;https://gist.github.com/statgeek/0c4aeec9053cf8050be18a03b842c1b9&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 22 Jun 2020 22:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Tabulate-Counts-and-Percentages-within-a-Single-Cell/m-p/664086#M198353</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-22T22:39:57Z</dc:date>
    </item>
  </channel>
</rss>

