```Date: Thu, 28 Jun 2007 17:36:56 -0000 Reply-To: SK Sender: "SAS(r) Discussion" From: SK Organization: http://groups.google.com Subject: Re: Count the proportion of days with exposure in specified time period Comments: To: sas-l@uga.edu In-Reply-To: <1183039788.103930.221480@q75g2000hsh.googlegroups.com> Content-Type: text/plain; charset="us-ascii" On Jun 28, 4:09 pm, frank_diio...@yahoo.com wrote: > On Jun 28, 9:14 am, SK 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 > > Here's an SQL-based solution: > > proc sql noprint; > create table summ as > select sum(feed=1)/count(*) as propFeed1 format=4.2, > sum(feed=2)/count(*) as propFeed2 format=4.2, > sum(feed=3)/count(*) as propFeed3 format=4.2 > from propFeed > group by id > ; > quit; Frank, It seems to work; but, have another request. I am not a seasoned SAS or sql programmer, but understand syntaxes if shown. What I am struggling with it 'spitting' out the summ table with the id attached to the newly created fields (propfeed1,2 3). like so: id propfeed1 propfeed2 propfeed3 1 0.14 0.86 0.0 how do I make the proc sql do this for me? Thanks, SK ```

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