<?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 getting n's and col percents on the same line in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711547#M219214</link>
    <description>&lt;P&gt;Nevermind - I figured it out! I added colpctn instead of just pctn.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc tabulate data = mtch_abcovng5 missing s=[foreground=black just=c cellwidth=700 ]; 
class fresult  age_4cat race_f faccode cdms_lab; 
var age1_new; 
tables  age1_new="Age at collection date (Mean)"
		age_4cat="Age categorized"
	    race_f = "Race/ethnicity"
	    faccode = "Ordering facility for negatives"
	    cdms_lab = "Ordering facility for positives",
	    fresult = "AB result"*(n='' * [style=[just=R cellwidth=90 borderrightstyle = hidden] ]
	    		 colpctn = '' * [style=[just=L cellwidth=110 borderleftstyle = hidden] f=paren.]);
title "Demographics of AB from April 20th to September 1st"; 
title2 "Among people with only AB tests (no PCR or both)"; 	
where ((ab_colldate_new lt '01SEP2020'd and ab_colldate_new ne .) or (neg_colldate lt "01SEP2020"d and neg_colldate ne . and neg_test = 'AB')) ;
run; &lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Jan 2021 20:16:09 GMT</pubDate>
    <dc:creator>claremc</dc:creator>
    <dc:date>2021-01-14T20:16:09Z</dc:date>
    <item>
      <title>Proc tabulate getting n's and col percents on the same line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711135#M219001</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently trying to use proc tabulate to create a demographics table. I want the frequency of each variable (the n) to appear in the same box as the column percent in parentheses. I ran this code after reading&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings13/289-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/289-2013.pdf&lt;/A&gt;&amp;nbsp;:&lt;/P&gt;&lt;PRE&gt;proc format;
 picture paren (round)
 low-high = '(009.9)'
 ( prefix = '(' );
run; 

proc tabulate data=mtch_abcovng5;
 class age_4cat;
 table age_4cat=''*(n = '' * [style=[just=R cellwidth=90 borderrightstyle = hidden] ]
 pctn = '' * [style=[just=L cellwidth=110 borderleftstyle = hidden] f=paren.]);
/*  format age_4cat age_4catl.; */
run;&lt;/PRE&gt;&lt;P&gt;My table came out how I want it to -&amp;nbsp;&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="claremc_0-1610549225899.png" style="width: 759px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53459i24E2FE0C8C1EFFF1/image-dimensions/759x56?v=v2" width="759" height="56" role="button" title="claremc_0-1610549225899.png" alt="claremc_0-1610549225899.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But when I run my actual demographics table employing the exact same format as above, the column percents appear below the number in a separate row (code and screenshot below).&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc tabulate data = mtch_abcovng5 missing s=[foreground=black just=c cellwidth=700 ]; 
class fresult  age_4cat race_f faccode cdms_lab; 
var age1_new; 
tables  age1_new="Age at collection date (Mean)"*(mean=' ')
		age_4cat="Age categorized"*(n = '' * [style=[just=R cellwidth=90 borderrightstyle = hidden] ]
		 pctn = '' * [style=[just=L cellwidth=110 borderleftstyle = hidden] f=paren.])
	    race_f = "Race/ethnicity"*(n = '' * [style=[just=R cellwidth=90 borderrightstyle = hidden] ]
	    	 pctn = '' * [style=[just=L cellwidth=110 borderleftstyle = hidden] f=paren.])
	    faccode = "Ordering facility for negatives"*(n = '' * [style=[just=R cellwidth=90 borderrightstyle = hidden] ]
	     pctn = '' * [style=[just=L cellwidth=110 borderleftstyle = hidden] f=paren.])
	    cdms_lab = "Ordering facility for positives"*(n = '' * [style=[just=R cellwidth=90 borderrightstyle = hidden] ]
	    pctn = '' * [style=[just=L cellwidth=110 borderleftstyle = hidden] f=paren.]),
	    fresult*([style=[cellwidth=110]]);
title "Demographics of AB from April 20th to September 1st"; 
title2 "Excluding people with both AB and PCR tests"; 	
where ((ab_colldate_new lt '01SEP2020'd and ab_colldate_new ne .) or (neg_colldate lt "01SEP2020"d and neg_colldate ne . and neg_test = 'AB')) ;
run; &lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="claremc_1-1610549322446.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53460iA238C5AB91DB61FC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="claremc_1-1610549322446.png" alt="claremc_1-1610549322446.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any ideas of how to get the column percents on the same line here?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clare&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 14:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711135#M219001</guid>
      <dc:creator>claremc</dc:creator>
      <dc:date>2021-01-13T14:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate getting n's and col percents on the same line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711162#M219015</link>
      <description>&lt;P&gt;Proc Tabulate will &lt;STRONG&gt;not&lt;/STRONG&gt; place two statistics "in the same box".&lt;/P&gt;
&lt;P&gt;You can use a style or override style settings for cell boundaries so the "box" does not appear but the values will be in different cells.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, do you want the appearance&amp;nbsp; of being in the same "cell", or do you actually want the values to be in a single "cell".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: if you want things to appear side by side then the statistic has to be in the COLUMN dimension. The construct you are using has the statistics in the ROW dimension.&lt;/P&gt;
&lt;P&gt;The Table statement in Proc tabulate when you have two dimensions have everything before the first comma as the row dimension so:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Table classvariable *(statistic otherstatistic) 
         ,
         otherclassvar anotherclassvar
       / &amp;lt;table options&amp;gt;
;
&lt;BR /&gt;
&lt;/PRE&gt;
&lt;P&gt;Places the statistics on two rows for each level of Classvariable. Note that I place the comma separating the dimensions where it is easy to see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the statistics side by side then the structure likely would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Table classvariable
         ,
        ( otherclassvar anotherclassvar)  *(statistic otherstatistic)  
       / &amp;lt;table options&amp;gt;
;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 15:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711162#M219015</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-13T15:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate getting n's and col percents on the same line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711170#M219021</link>
      <description>Yay that worked thanks so much!</description>
      <pubDate>Wed, 13 Jan 2021 16:08:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711170#M219021</guid>
      <dc:creator>claremc</dc:creator>
      <dc:date>2021-01-13T16:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate getting n's and col percents on the same line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711173#M219022</link>
      <description>&lt;P&gt;Thanks so much -- that worked! One follow-up question -- do you know how to format the cell for ONLY continuous variables? So putting the mean (SD) for a continuous variable but keeping the formatting for class variables? I have one continuous variable that needs to be in mean (SD) format. See screenshot below.&amp;nbsp;&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="claremc_1-1610554248436.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53466i5520BFE8967D1B99/image-size/medium?v=v2&amp;amp;px=400" role="button" title="claremc_1-1610554248436.png" alt="claremc_1-1610554248436.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have tried adding this formatting statement below which I think I would then apply to the continuous variable, but I'm not sure where to add it.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc format; 
 picture lcl (round) /* Lower limit requires a left parenthesis and a comma on the right */
 low-high = '009.99,'
 ( prefix = '(' );
 picture ucl (round)
 low-high = '009.99)'; /* Upper limit requires only a right parenthesis */

run; &lt;/PRE&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clare&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 16:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711173#M219022</guid>
      <dc:creator>claremc</dc:creator>
      <dc:date>2021-01-13T16:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate getting n's and col percents on the same line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711192#M219033</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/359435"&gt;@claremc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks so much -- that worked! One follow-up question -- do you know how to format the cell for ONLY continuous variables? So putting the mean (SD) for a continuous variable but keeping the formatting for class variables? I have one continuous variable that needs to be in mean (SD) format. See screenshot below.&amp;nbsp;&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="claremc_1-1610554248436.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53466i5520BFE8967D1B99/image-size/medium?v=v2&amp;amp;px=400" role="button" title="claremc_1-1610554248436.png" alt="claremc_1-1610554248436.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I have tried adding this formatting statement below which I think I would then apply to the continuous variable, but I'm not sure where to add it.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format; 
 picture lcl (round) /* Lower limit requires a left parenthesis and a comma on the right */
 low-high = '009.99,'
 ( prefix = '(' );
 picture ucl (round)
 low-high = '009.99)'; /* Upper limit requires only a right parenthesis */

run; &lt;/PRE&gt;
&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clare&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm not quite sure I understand the question.&lt;/P&gt;
&lt;P&gt;It sounds like you want an N and Pctn of the Mean??? Tabulate won't cross statistics, you can't get an "n" of the "mean" if you want Tabulate to calculate the mean.&lt;/P&gt;
&lt;P&gt;If I was doing something similar to this in Proc Tabulate I would be tempted to have another table statement (you can have LOTS of tables in one call to proc tabulate) that just did the single variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tables age ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherclassvar *(mean sd)&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;lt;the other table definition&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the layout was similar to the other. There would be a space between the tables though. To make things look nice you may get into controlling the cell sizes with cellwidth style overrides so they align from table bit to table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 16:39:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711192#M219033</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-13T16:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate getting n's and col percents on the same line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711544#M219213</link>
      <description>&lt;P&gt;Thank you!!! I am going to separate out the continuous variables in a different table statement.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One more question..... I noticed my percents being output are not column percents, rather they are total percents... Here is my final code.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc format;
 picture paren (round)
 low-high = '(009.9)'
 ( prefix = '(' );
 run; 

proc tabulate data = mtch_abcovng5 missing s=[foreground=black just=c cellwidth=700 ]; 
class fresult  age_4cat race_f faccode cdms_lab; 
var age1_new; 
tables  age1_new="Age at collection date (Mean)"
		age_4cat="Age categorized"
	    race_f = "Race/ethnicity"
	    faccode = "Ordering facility for negatives"
	    cdms_lab = "Ordering facility for positives",
	    fresult = "AB result"*(n='' * [style=[just=R cellwidth=90 borderrightstyle = hidden] ]
	    		 pctn = '' * [style=[just=L cellwidth=110 borderleftstyle = hidden] f=paren.]);
title "Demographics of AB from April 20th to September 1st"; 
title2 "Among people with only AB tests (no PCR or both)"; 	
where ((ab_colldate_new lt '01SEP2020'd and ab_colldate_new ne .) or (neg_colldate lt "01SEP2020"d and neg_colldate ne . and neg_test = 'AB')) ;
run; &lt;/PRE&gt;&lt;P&gt;Any idea how to make it column?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Clare&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 20:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711544#M219213</guid>
      <dc:creator>claremc</dc:creator>
      <dc:date>2021-01-14T20:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate getting n's and col percents on the same line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711547#M219214</link>
      <description>&lt;P&gt;Nevermind - I figured it out! I added colpctn instead of just pctn.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc tabulate data = mtch_abcovng5 missing s=[foreground=black just=c cellwidth=700 ]; 
class fresult  age_4cat race_f faccode cdms_lab; 
var age1_new; 
tables  age1_new="Age at collection date (Mean)"
		age_4cat="Age categorized"
	    race_f = "Race/ethnicity"
	    faccode = "Ordering facility for negatives"
	    cdms_lab = "Ordering facility for positives",
	    fresult = "AB result"*(n='' * [style=[just=R cellwidth=90 borderrightstyle = hidden] ]
	    		 colpctn = '' * [style=[just=L cellwidth=110 borderleftstyle = hidden] f=paren.]);
title "Demographics of AB from April 20th to September 1st"; 
title2 "Among people with only AB tests (no PCR or both)"; 	
where ((ab_colldate_new lt '01SEP2020'd and ab_colldate_new ne .) or (neg_colldate lt "01SEP2020"d and neg_colldate ne . and neg_test = 'AB')) ;
run; &lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jan 2021 20:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-getting-n-s-and-col-percents-on-the-same-line/m-p/711547#M219214</guid>
      <dc:creator>claremc</dc:creator>
      <dc:date>2021-01-14T20:16:09Z</dc:date>
    </item>
  </channel>
</rss>

