LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (December 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 19 Dec 2006 05:59:14 -0800
Reply-To:     SK <skauchali@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SK <skauchali@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: Algorithm to create new var based on knowledge of date and
Comments: To: sas-l@uga.edu
In-Reply-To:  <200612191119.kBJ6Oefs016021@mailgw.cc.uga.edu>
Content-Type: text/plain; charset="iso-8859-1"

Yes, thanks, with this method, we have identified all the results that have a yes and date then it was yes-- something I wanted. Also we have marked those that did not have yes in the series of tests as no. Also what I wanted.

because I am doing an analysis that aims to find out the exact time when the result were YES, I need to know the last time when it was NO and the first time it was YES. So the final dataset should look like this:

childid date result datefirstyes datelastno test

101691 02JUL2002 No 101691 13AUG2002 Yes 13AUG2002 02JUL2002 YES 101691 01OCT2002 Yes 101691 05NOV2002 Yes 101691 26AUG2003 Yes 101691 30SEP2003 Yes

In this case I would be able to say that the test became YES somewhere between <datelastno> to <datefirstyes>. Those subjects that did not have any YES in the follow-up would only have a <datelastno> at the last DATE, i.e. datefirstyes would be missing for this child. For those that start the follow-up time with a YES, will have datefirstyes but no datelastno.

Thanks for the help, it is indeed much appreciated.

SK

On Dec 19, 1:19 pm, gerhard.hellrie...@T-ONLINE.DE (Gerhard Hellriegel) wrote: > so you need a dataset with all children fed up with the information when the > test was positive the first time, or missing if there was none. Is that right? > Have a look at the following: > > proc sort data=children; > by childid date; > run; > > data children; > retain res; > set children; > by childid; > if first.childid then res=0; > if upcase(result)="YES" then res+1; > run; > > proc sort; > by childid res; > run; > > data children; > set children; > retain test; > by childid; > if res=0 then test=.; > if res=1 then test=date; > if last.childid then output; > format test date9.; > run; > > Is that what you need? > Regards, > Gerhard > > On Tue, 19 Dec 2006 02:36:37 -0800, SK <skauch...@GMAIL.COM> wrote: > >Hi There (sorry this is a long message; I have tried to keep it clear; > >let me know if there is further information you require) > > >Let me start by admitting that I am not an expert at repeated > >observation in SAS, and I think I should spend time learning it before > >I resort to asking more question here. I have Cody's book (long. data > >and SAS), which seems to help. But I thought I would post to fast track > >my objectives. Here is the problem: data table is as > > >Childid date result > >100611 19FEB2002 No > >100611 11JUN2002 No > >100611 08JUL2003 No > >100611 08JUL2004 No > >100651 09APR2002 No > >100651 15OCT2003 No > >101061 30APR2002 No > >101061 27AUG2002 No > >101061 12NOV2002 No > >101121 16MAY2002 No > >101121 16JUL2002 Yes > >101161 22JAN2002 No > >101161 21MAY2002 No > >101271 11DEC2001 No > >101271 02APR2002 No > >101271 22APR2003 No > >101361 02APR2002 No > >101361 25JUL2002 No > >101361 19MAY2003 No > >101371 29JAN2002 No > >101371 21MAY2002 No > >101371 01JUL2003 No > >101391 26MAR2002 No > >101391 23JUL2002 No > >101391 19MAY2003 Yes > >101561 26MAR2002 No > >101611 02JAN2002 No > >101611 29JAN2002 No > >101651 26MAR2002 No > >101651 24JUL2002 No > >101651 01SEP2003 No > >101691 02JUL2002 No > >101691 13AUG2002 Yes > >101691 01OCT2002 Yes > >101691 05NOV2002 Yes > >101691 26AUG2003 Yes > >101691 30SEP2003 Yes > >101711 21MAY2002 Yes > >101711 02JUL2002 Yes > >101711 03SEP2002 Yes > >101711 14JUL2003 Yes > >307511 30NOV2004 Yes > >307601 26APR2005 No > > >As you can see, a child has had either just one measurement or multiple > >measurements (result) at different dates. The RESULT is a test result. > >If the child test YES at a date, then the test is positive > >(TEST=positive). If RESULT is NO on all dates then the TEST=negative. > >What is important is the date when the RESULT was YES. > > >I would like to program in SAS an algorithm that will identify a child > >who is test positive and date when it was positive. So for example, > >these 2 children > >307511 30NOV2004 Yes > >307601 26APR2005 No > >only had one test done. If child only has one obs then TEST=RESULT and > >DATETEST=DATE- in these 2 cases the data will look like this: > > >Childid date result test datetest > >307511 30NOV2004 Yes Yes 30NOV2004 > >307601 26APR2005 No No 26APR2005 > > >In cases where the child had more than one obs, it is a bit tricky for > >me. If any of the dates had a RESULT=YES, then TEST=YES and DATETEST= > ><date when first time when RESULT=YES>; Take this subject as an > >example: > > >Childid date result test > >datetest > >101691 02JUL2002 No > >101691 13AUG2002 Yes Yes 13AUG2002 > >101691 01OCT2002 Yes > >101691 05NOV2002 Yes > >101691 26AUG2003 Yes > >101691 30SEP2003 Yes > > >If all of the results on all dates are NO, then the test is also NO; > >and the last date of result is recorded; thus: > >Childid date result test > >datetest > >101361 02APR2002 No > >101361 25JUL2002 No > >101361 19MAY2003 No No 19MAY2003 > > >If I look at this, it would seem that subjects with only one > >measurement are a special case of multiple obs (where the wave is equal > >to one). > > >I would like to then take the obs that have a test and datetest var > >populated as above from this dataset and merge it with the flat data > >set with all children in it. Can someone help me with the code and > >direction. > > >Thanks > >SK


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