From: Mary on
Kim,

I don't think you can do it with proc tabulate, but it is very easy with proc report- maybe save your output as a data set out of tabulate (though actually, the ODS output out of tabulate is very bad; so it much easier to generate your numbers out of proc means, summary, or freq first), then use proc report. Here is how to do it out of proc report- my line is light grey, note the compute after statements at the end:

proc report data=univariate_all nowindows;
title "title";
title2 " ";
column
drug
month
bpl
n
mean
p_0
p_10
p_20
p_30
p_40
p_50
p_60
p_70
p_80
p_90
p_100;

define drug/group "Drug " style(column)=[tagattr='format:#,##0' just=l] style(header)=[background=lightgrey Just=l];
define bpl/group "BPL Status " style(column)=[tagattr='format:#,##0' just=l] style(header)=[background=lightgrey Just=l];
define month/display "Month" style(column)=[tagattr='format:#,##0' just=l] style(header)=[background=lightgrey Just=l];
define n/display "N" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define mean/display "Mean Fill Qty" style(column)=[tagattr='format:#,##0.00' just=R] style(header)=[background=lightgrey Just=r];
define p_0/display "P_0" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define p_10/display "P_10" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define p_20/display "P_20" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define p_30/display "P_30" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define p_40/display "P_40" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define p_50/display "P_50" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define p_60/display "P_60" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define p_70/display "P_70" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define p_80/display "P_80" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define p_90/display "P_90" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
define p_100/display "P_100" style(column)=[tagattr='format:#,##0' just=R] style(header)=[background=lightgrey Just=r];
compute after drug/style=[background=lightgrey];
line ' ';
endcomp;
compute after bpl/style=[background=lightgrey];
line ' ';
endcomp;
run;


-Mary


--- kibrown(a)LADHS.ORG wrote:

From: Kim Brown <kibrown(a)LADHS.ORG>
To: SAS-L(a)LISTSERV.UGA.EDU
Subject: Proc Tabulate-adding a row
Date: Fri, 12 Feb 2010 17:09:43 -0500

Hi
Does anyone know of an option that would insert a row between variables?
For example: between gender, age & race/ethnicity.
Thanks for any ideas.
Kim
month=May-09

SITE Total
A B C
Sum ColPctSum Sum ColPctSum Sum ColPctSum
Sum ColPctSum
Total 773 100.00% 793 100.00% 497 100.00% 2063 100.00%
Gender 317 41.00% 312 39.34% 199 40.04% 828 40.13%
Female
Male 456 58.99% 481 60.65% 298 59.95% 1235 59.86%
Age 18 2.32% . . 15 3.01% 33 1.59%
0 to 12
13 to 17 61 7.89% . . 69 13.88% 130
6.30%
18+ 694 89.78% 793 100.00% 413 83.09% 1900 92.09%
Race/Ethnicity 35 4.52% 37 4.66% 16 3.21% 88
4.26%
Asian
Black 279 36.09% 193 24.33% 73 14.68% 545 26.41%
Hispanic/Latino 240 31.04% 358 45.14% 178 35.81% 776
37.61%
Native American . . . . 1 0.20% 1
0.04%
White 187 24.19% 186 23.45% 229 46.07% 602 29.18%
Other/Unknown 32 4.13% 19 2.39% . . 51
2.47%
From: Arthur Tabachneck on
Kim,

One way to achieve what I think you want is to simply make the variable
label so long that it requires 2 or more lines to print.

You didn't include your code, thus I'll use the following as an example:

proc tabulate data=ex1;
class ptn treat visit;
var score1 score2;
table treat='Treatment' visit='Visit',
mean=' '*score1='Drug A'*ptn='Patient Id';
format treat tr. visit vi.;
run;

If you want an extra space between the summary for 'Treatment' and the
summary for 'Visit', the only change that has to be made is to the initial
table line:
from:
table treat='Treatment' visit='Visit',

to:
table treat='Treatment' visit=' Visit',

However, you have to imbed a non-printable character before the leading
spaces in ' Visit'

There is probably a cleaner way of doing it, but I typically do it by
entering an ASCII 255 character.
i.e., type: table treat='Treatment' visit='
then press the alt key, keep it depressed, and enter the number 255 using
your number keypad, then release the alt key. After that type a bunch of
spaces, followed by: Visit',

Yes, admittedly kludgy, but it might solve your current problem.

HTH,
Art
---------
On Fri, 12 Feb 2010 17:09:43 -0500, Kim Brown <kibrown(a)LADHS.ORG> wrote:

>Hi
>Does anyone know of an option that would insert a row between variables?
>For example: between gender, age & race/ethnicity.
>Thanks for any ideas.
>Kim
>month=May-09
>
> SITE Total
> A B C
> Sum ColPctSum Sum ColPctSum Sum ColPctSum
> Sum ColPctSum
>Total 773 100.00% 793 100.00% 497 100.00% 2063 100.00%
>Gender 317 41.00% 312 39.34% 199 40.04% 828 40.13%
>Female
>Male 456 58.99% 481 60.65% 298 59.95% 1235 59.86%
>Age 18 2.32% . . 15 3.01% 33 1.59%
>0 to 12
>13 to 17 61 7.89% . . 69 13.88% 130
> 6.30%
>18+ 694 89.78% 793 100.00% 413 83.09% 1900 92.09%
>Race/Ethnicity 35 4.52% 37 4.66% 16 3.21% 88
> 4.26%
>Asian
>Black 279 36.09% 193 24.33% 73 14.68% 545 26.41%
>Hispanic/Latino 240 31.04% 358 45.14% 178 35.81% 776
> 37.61%
>Native American . . . . 1 0.20% 1
> 0.04%
>White 187 24.19% 186 23.45% 229 46.07% 602 29.18%
>Other/Unknown 32 4.13% 19 2.39% . . 51
> 2.47%
From: xlr82sas on
On Feb 13, 7:57 am, art...(a)NETSCAPE.NET (Arthur Tabachneck) wrote:
> Kim,
>
> One way to achieve what I think you want is to simply make the variable
> label so long that it requires 2 or more lines to print.
>
> You didn't include your code, thus I'll use the following as an example:
>
> proc tabulate data=ex1;
>   class ptn treat visit;
>   var score1 score2;
>   table treat='Treatment' visit='Visit',
>         mean=' '*score1='Drug A'*ptn='Patient Id';
>   format treat tr. visit vi.;
> run;
>
> If you want an extra space between the summary for 'Treatment' and the
> summary for 'Visit', the only change that has to be made is to the initial
> table line:
> from:
>   table treat='Treatment' visit='Visit',
>
> to:
>   table treat='Treatment' visit='                               Visit',
>
> However, you have to imbed a non-printable character before the leading
> spaces in '                        Visit'
>
> There is probably a cleaner way of doing it, but I typically do it by
> entering an ASCII 255 character.
> i.e., type: table treat='Treatment' visit='
> then press the alt key, keep it depressed, and enter the number 255 using
> your number keypad, then release the alt key.  After that type a bunch of
> spaces, followed by: Visit',
>
> Yes, admittedly kludgy, but it might solve your current problem.
>
> HTH,
> Art
> ---------
>
>
>
> On Fri, 12 Feb 2010 17:09:43 -0500, Kim Brown <kibr...(a)LADHS.ORG> wrote:
> >Hi
> >Does anyone know of an option that would insert a row between variables?
> >For example: between gender, age & race/ethnicity.
> >Thanks for any ideas.
> >Kim
> >month=May-09
>
> >                             SITE                            Total
> >                                A B C
> > Sum ColPctSum Sum ColPctSum Sum ColPctSum
> > Sum ColPctSum
> >Total 773 100.00% 793 100.00% 497 100.00% 2063 100.00%
> >Gender 317 41.00% 312 39.34% 199 40.04% 828 40.13%
> >Female
> >Male 456 58.99% 481 60.65% 298 59.95% 1235 59.86%
> >Age 18 2.32% . . 15 3.01% 33 1.59%
> >0 to 12
> >13 to 17 61 7.89% . . 69 13.88% 130
> > 6.30%
> >18+ 694 89.78% 793 100.00% 413 83.09% 1900 92.09%
> >Race/Ethnicity 35 4.52% 37 4.66% 16 3.21% 88
> > 4.26%
> >Asian
> >Black 279 36.09% 193 24.33% 73 14.68% 545 26.41%
> >Hispanic/Latino 240 31.04% 358 45.14% 178 35.81% 776
> > 37.61%
> >Native American . . . . 1 0.20% 1
> > 0.04%
> >White 187 24.19% 186 23.45% 229 46.07% 602 29.18%
> >Other/Unknown 32 4.13% 19 2.39% . . 51
> > 2.47%- Hide quoted text -
>
> - Show quoted text -

Hi,

Just to add a little to Art's excellent response.

If you are using a laptop without a numpad, you can:

1. Hit the function key(blue fn key on my hp laptop) and numlock key
2 Hold the alt key down and type kii then
3. Turn the function key off.

This will insert what looks like a blank.

This is sometimes called the hiddon dragon and works well for pdf and
rtf output.

You can find moe info on www.lexjansen.com - search 'hiddon dragon'.

Regards
From: Kim Brown on
Thanks everyone for your suggestions.

Art,
Here is a copy of my code:


/*Original Code*/
ods html file='C:\ZENWORKS\WANT.xls';
proc tabulate data=HAVE format=4.;
format site sitefmt. race_eth racefmt. month monthsfmt. los losfmt.
residence residencefmt. brought_by brought_byfmt. admit_legal2
admit_legalfmt. agecat agefmt. ;

class site race_eth los gender agecat residence brought_by admit_legal2;
by month;
var total1;
table ALL gender agecat race_eth los residence brought_by admit_legal2,
site='SITE' *total1=' '*(sum colpctsum*f=pctfmt9.) all*total1=' '*( sum
colpctsum*f=pctfmt9.) /RTS=15 ;
where '01MAY09'd LE disch_date LE '31OCT09'd;
Title 'Happy SAS People May to October 2009';
Label gender='Gender' agecat='Age' race_eth='Race/Ethnicity' los='Length
of Stay' residence='Residence Status' brought_by='Admit Source'
admit_legal2='Admit Legal Status' ;
Keylabel All ='Total' ;
run;
ods html close;

/*Modifield*/
ods html file='C:\ZENWORKS\WANT.xls';
proc tabulate data=HAVE format=4.;
format site sitefmt. race_eth racefmt. month monthsfmt. los losfmt.
residence residencefmt. brought_by brought_byfmt. admit_legal2
admit_legalfmt. agecat agefmt. ;

class site race_eth los gender agecat residence brought_by admit_legal2;
by month;
var total1;
table ALL race_eth=' Race/Ethnicity' los=' Length of
Stay' agecat=' Age'
residence=' Residence Status' brought_by=' Admit
Source' admit_legal2=' Admit Legal Status' ,site='SITE'
*total1=' '*(sum colpctsum*f=pctfmt9.) all*total1=' '*( sum
colpctsum*f=pctfmt9.) /RTS=15 ;
where '01MAY09'd LE disch_date LE '31OCT09'd;
Title 'Happy SAS People May to October 2009';
Keylabel All ='Total' ;
run;
ods html close;


I tried to modified the code and tried holding the ATL key down & press
255 but output did not changed. I'm not sure what I'm doing wrong...any
assistance will be appreciated.
Thanks again,
Kim
From: Arthur Tabachneck on
Kim,

In your proc tabulate statement you specify: /RTS=15

That will limit the width of your heading to 15 characters, thus negate
any attempt to fool SAS into adding an extra space. I changed it to:

colpctsum*f=pctfmt9.) /* /RTS=15 */

and it appears to do what I thought you wanted.

Art
---------
On Tue, 16 Feb 2010 14:29:48 -0500, Kim Brown <kibrown(a)LADHS.ORG> wrote:

>Thanks everyone for your suggestions.
>
>Art,
>Here is a copy of my code:
>
>
>/*Original Code*/
>ods html file='C:\ZENWORKS\WANT.xls';
>proc tabulate data=HAVE format=4.;
>format site sitefmt. race_eth racefmt. month monthsfmt. los losfmt.
>residence residencefmt. brought_by brought_byfmt. admit_legal2
>admit_legalfmt. agecat agefmt. ;
>
>class site race_eth los gender agecat residence brought_by admit_legal2;
>by month;
>var total1;
>table ALL gender agecat race_eth los residence brought_by admit_legal2,
>site='SITE' *total1=' '*(sum colpctsum*f=pctfmt9.) all*total1=' '*( sum
>colpctsum*f=pctfmt9.) /RTS=15 ;
>where '01MAY09'd LE disch_date LE '31OCT09'd;
>Title 'Happy SAS People May to October 2009';
>Label gender='Gender' agecat='Age' race_eth='Race/Ethnicity' los='Length
>of Stay' residence='Residence Status' brought_by='Admit Source'
>admit_legal2='Admit Legal Status' ;
>Keylabel All ='Total' ;
>run;
>ods html close;
>
>/*Modifield*/
>ods html file='C:\ZENWORKS\WANT.xls';
>proc tabulate data=HAVE format=4.;
>format site sitefmt. race_eth racefmt. month monthsfmt. los losfmt.
>residence residencefmt. brought_by brought_byfmt. admit_legal2
>admit_legalfmt. agecat agefmt. ;
>
>class site race_eth los gender agecat residence brought_by admit_legal2;
>by month;
>var total1;
>table ALL race_eth=' Race/Ethnicity' los=' Length of
>Stay' agecat=' Age'
>residence=' Residence Status' brought_by=' Admit
>Source' admit_legal2=' Admit Legal Status' ,site='SITE'
>*total1=' '*(sum colpctsum*f=pctfmt9.) all*total1=' '*( sum
>colpctsum*f=pctfmt9.) /RTS=15 ;
>where '01MAY09'd LE disch_date LE '31OCT09'd;
>Title 'Happy SAS People May to October 2009';
>Keylabel All ='Total' ;
>run;
>ods html close;
>
>
>I tried to modified the code and tried holding the ATL key down & press
>255 but output did not changed. I'm not sure what I'm doing wrong...any
>assistance will be appreciated.
>Thanks again,
>Kim