LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2002, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 14 Jun 2002 15:00:03 -0400
Reply-To:     "Huang, Ya" <ya.huang@PFIZER.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Huang, Ya" <ya.huang@PFIZER.COM>
Subject:      Re: Proc tabulate
Comments: To: ROTH Fabrice <fabrice.roth@STATEC.ETAT.LU>
Content-Type: text/plain

Roth,

You can calculate the ratio in data step, make a new category for t, then feed the data into proc tabulate: Assuming t=0 is for mother, t=1 is for kids, let t=3 for desc ratio. t=3 will only have one record for each annis:

proc format; value mkd 0='Female' 1='Kids' 2='descendent' ;

data xx; do annis='1910','1911'; do j=1 to 1000; t=rannor(0)<0.5; r1=1; output; end; end;

** this is what you did ; proc tabulate formchar='|----|+|---'; class annis t; var r1; table annis=''*t='', r1='Nationalite'*sum=''*f=best14.; format t mkd.; run;

** calculate ratio in data step, for each annis, add a new; ** record, which t=3 and r1=the ratio calculated;

proc sort data=xx; by annis t;

data xx; set xx; retain st0 st1; by annis t; output; if first.annis then do; st0=0; st1=0; end; if t=0 then st0+1; if t=1 then st1+1; if last.annis then do; t=2; r1=round(st1/st0,.01); output; end;

proc tabulate formachar='|----|+|---'; class annis t; var r1; table annis=''*t='', r1='Nationalite'*sum=''*f=best14.; format t mkd.; run;

------------------------ This is what you got: ------------------------------------------------------ | | Nationalite | |-------------------------------------+--------------| |1910 |Female | 315| | |------------------+--------------| | |Kids | 685| |------------------+------------------+--------------| |1911 |Female | 309| | |------------------+--------------| | |Kids | 691| ------------------------------------------------------

This is what I got after adding the new record:

------------------------------------------------------ | | Nationalite | |-------------------------------------+--------------| |1910 |Female | 315| | |------------------+--------------| | |Kids | 685| | |------------------+--------------| | |descendent | 2.17| |------------------+------------------+--------------| |1911 |Female | 309| | |------------------+--------------| | |Kids | 691| | |------------------+--------------| | |descendent | 2.24| ------------------------------------------------------

Hope this helps.

Kind regards,

Ya Huang

-----Original Message----- From: ROTH Fabrice [mailto:fabrice.roth@STATEC.ETAT.LU] Sent: Thursday, June 13, 2002 10:45 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Proc tabulate

Hello everybody

Let me give you first an example:

nationalities ... 1910 female 10479 ... kids 14299 ... descendent 1,36 ...

1911 female 1219 ... kids 1933 ... descendent 1,59 ... ...

What I've calculated is a Table with Proc Tabulate that gives me the number of women born on the date mentioned (1910 1911 ... 2001) as well ass the children they gave birth to. I've done that by using this PROC Tabulate statement:

proc tabulate data=vol4.t440 missing out=vol4.r_t440(drop=_type_ _page_ _table_); class annais t; var r1 r2 r3 r4 r5 r6 r7 r8 ; table annais*t, ' '='Nationalite'*(r1*sum=''*f=12. ) run;

The variable t groups the kids and the mothers.

The problem I have is to calculate the descendent for each date of birth, that is for each group (1910 1911 ...) (kids/female). I know how to do it in a separate DATA step, but I wanted to ask whether it is possible to do it in the TABULATE as I have to output it in the PROC Tabulate style?

Thanks


Back to: Top of message | Previous page | Main SAS-L page