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 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 28 Jun 2007 21:52:36 -0400
Reply-To:   "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject:   Re: Count the proportion of days with exposure in specified time period

On Thu, 28 Jun 2007 06:14:18 -0700, SK <skauchali@GMAIL.COM> wrote:

>Hi there, this is a newbie-type question. > >I have a longitudinal dataset of daily feeding records of infants from >birth to 270 days (9 months). Infant feeding (category) for the each >day is recorded at either exclusive breast =1), mixed feeding (=2), >and exclusive formula (=3). I wish to count the proportion of days a >child receives either 1, 2 or 3. > >Data structure and intended variable after manipulation (propfeed): > >id Feed >1 1 >1 1 >1 2 >1 3 >2 1 >2 1 >2 1 >2 1 >3 3 >3 3 >3 3 >etc > > >Desired table: >id propfeed1 propfeed2 propfeed3 >1 0.5 0.25 0.25 >2 1.0 0 0 >3 0 0 1.0 >etc. > >Could someone help guide me through this problem? >thank you, > >SK

Is the purpose here to generate a report, or a data set to be used in subsequent processing?

For a report, consider PROC TABULATE. Your data are well organized and would seem to need no pre-processing.

Load:

data have; input id Feed ; cards; 1 1 1 1 1 2 1 3 2 1 2 1 2 1 2 1 3 3 3 3 3 3 ;

Create the report:

proc tabulate data=have formchar="|-+-+|+|+-+"; class id feed; table pctn<feed> , id , feed='PropFeed' ; run;

Output:

PctN +-------------------------------------------------------------+ | | PropFeed | | |--------------------------------------| | | 1 | 2 | 3 | |----------------------+------------+------------+------------| |id | | | | |----------------------| | | | |1 | 50.00| 25.00| 25.00| |----------------------+------------+------------+------------| |2 | 100.00| .| .| |----------------------+------------+------------+------------| |3 | .| .| 100.00| +-------------------------------------------------------------+


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