Re: proc tabulate #4

  • Follow


On Thu, 2 Oct 2003 16:22:56 -0700, Liyan Liu <liyanliu888@YAHOO.COM> wrote:

>Dear fellow SAS professionals,
>
>I have a dataset with 3 variables
>hosp -- hospitalized for at least once (1,0)
>sex  -- m,f
>grp -- 1,2,3
>
>How could I use the PROC TABULATE procedure to produce
>a table like:
>
>-----------------------------------------------------
>                 m              f               total
>         --------------   -------------------
>         grp1 grp2 grp3   grp1 grp2 grp3
>-----------------------------------------------------
>hosp
>  1
>  0
>-----------------------------------------------------
>Inside the table is the number of people hospitalized.
>Thanks so much.
>
>Liyan
>
>__________________________________
>Do you Yahoo!?
>The New Yahoo! Shopping - with improved product search
>http://shopping.yahoo.com
Assuming you just want to count the observations of people,
you don't need those dummary var variables.
Using Jack's test data, just use the n statistic with all class variables.
Note that I added a format (n*f=5.) to print whole numbers.

data test;

   do hosp = 0, 1;
      do sex = 'm', 'f';
         do grp = 1, 2, 3;
             output;
         end;
      end;
   end;
run;

options nocenter;

proc tabulate data=test;

   class hosp / descending;
   class sex  / descending;
   class grp;


   keylabel n=' ';

   table hosp, (sex all='Total')*grp*n*f=5.
         / rts=6;

run;


produces this output :


------------------------------------------------------------
|    |                sex                |                 |
|    |-----------------------------------|                 |
|    |        m        |        f        |      Total      |
|    |-----------------+-----------------+-----------------|
|    |       grp       |       grp       |       grp       |
|    |-----------------+-----------------+-----------------|
|    |  1  |  2  |  3  |  1  |  2  |  3  |  1  |  2  |  3  |
|----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|hosp|     |     |     |     |     |     |     |     |     |
|----|     |     |     |     |     |     |     |     |     |
|1   |    1|    1|    1|    1|    1|    1|    2|    2|    2|
|----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|0   |    1|    1|    1|    1|    1|    1|    2|    2|    2|
------------------------------------------------------------

Dianne Louise Rhodes
Sr. Systems Analyst (and tabulate queen)
Westat
0
Reply RHODESD1 (150) 10/3/2003 5:48:47 PM


0 Replies
28 Views

(page loaded in 0.036 seconds)


Reply: