|
To directly generate this in tabulate, I think you need two extra logical variables:
a constant allHands = 1
a logical lefty = 1 when the obs is for a left-hander otherwise zero
If your data volumes preclude regenerating the data with the two extra columns, they can be created in a datastep view, like
data x/ view=x ;
set lefty ;
lefty = ( hand='L' );
retain allHands 1;
run;
Then you can use the format of denominator definition where
instead of the denominator being the total sum/freq across that class,
you use an analysis variable to be totalled at that class crossing
Your cell will show the total of lefty divided by the total of allHands.
proc tabulate;
class campus sex hand;
var lefty allHands;
table campus,
all = 'Total' * F = 5.0
sex * ( n = 'N' * f = 5.0
pctn< sex > = '%' * f = 5.1 ) /* normal denominator */
lefty* ( sum = 'num' * f = 5.0
pctsum< allHands>= '%' * f = 5.1 )
/* denominator is analysis variable */
/ rts=10;
run;
Datum: 15.08.2000 15:14
An: SAS-L@listserv.uga.edu
Antwort an: bill.leblanc@celebration.fl.us
Betreff: omit column in proc tabulate
Nachrichtentext:
I would like to display some frequency data using proc tabulate, but
with a little twist. I'd like to concatenate class variables, and for
some of them, I'd like to omit the display of some levels without
omitting the entire observation. An example will make this clear:
**how to show all males/females, but only the lefties in a tabulate
table;
data lefty;
infile cards missover;
input campus $
sex $
hand $;
cards;
E M L
E M R
E M L
E M R
E F L
E F L
E F R
E F L
W M R
W F R
W M L
W M L
W M L
W F R
W F L
;
proc tabulate;
class campus sex hand;
tables campus, all = 'Total' * F = 5.0
(sex hand ) *
(n='N' * f = 5.0 pctn<sex hand all> = '%' * f =
5.1 )/rts=10;
run;
produces:
----------------------------------------------------------------
| | | sex | hand |
| | |-----------------------+-----------------------|
| |Total| F | M | L | R |
| |-----+-----------+-----------+-----------+-----------|
| | N | N | % | N | % | N | % | N | % |
|--------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|campus | | | | | | | | | |
|--------| | | | | | | | | |
|E | 8| 4| 50.0| 4| 50.0| 5| 62.5| 3| 37.5|
|--------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|W | 7| 3| 42.9| 4| 57.1| 4| 57.1| 3| 42.9|
----------------------------------------------------------------
I would like to keep the 15 subjects for some of the column variables
(in this case 'sex'), but eliminate some subjects for other column
variables (in this case the 6 right-handers), so that my table looks
like:
----------------------------------------------------
| | | sex | hand |
| | |-----------------------+------------
| |Total| F | M | L |
| |-----+-----------+-----------+-----------+
| | N | N | % | N | % | N | % |
|--------+-----+-----+-----+-----+-----+-----+-----+
|campus | | | | | | | |
|--------| | | | | | | |
|E | 8| 4| 50.0| 4| 50.0| 5| 62.5|
|--------+-----+-----+-----+-----+-----+-----+-----+
|W | 7| 3| 42.9| 4| 57.1| 4| 57.1|
----------------------------------------------------
All percents would be based on the total row N's of 8 and 7.
Subsetting on the lefthanders, or deleting the 'R' values and using the
'missing' option does not give me what I need. In the case of the
former, I'll lose 6 males and females, and in the case of the latter,
I'll have N and % columns for the missings, which is what I want to
supress.
The extension of this would be to tack on more column variables, eg,
Race showing only the privileged, Religion showing only the chosen, etc,
while still being able to display all levels for all subjects in other
variables.
TIA,
Bill LeBlanc
Institutional Research
Valencia Community College
att-1.htm [text/html]
|