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 02:36:37 -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:      Algorithm to create new var based on knowledge of date and other
              var
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset="iso-8859-1"

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