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 (August 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 13 Aug 2000 14:12:25 -0700
Reply-To:     Lauren E Haworth <haworthl@MINDSPRING.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Lauren E Haworth <haworthl@MINDSPRING.COM>
Organization: MindSpring Enterprises
Subject:      Re: data step question

Haiyi,

The following code should do the trick. It uses arrays to find the first time an ON was followed by an OFF, and the grabs the two outcome measures.

data onoff; input id t1-t5 m1-m5; array times {*} t1-t5; array outcomes {*} m1-m5;

do I=1 to (dim(times)-1); if times{I}=1 and times{I+1}=0 and m_on=. then do; m_on=outcomes{I}; m_off=outcomes{I+1}; end; end; cards; 1 1 1 1 1 1 44 28 38 30 31 2 1 0 1 0 0 69 50 74 65 . 3 1 1 1 1 0 43 40 37 36 50 4 1 0 1 1 1 74 . 62 67 . 5 1 1 0 0 0 45 38 . 43 44 6 1 0 0 1 0 56 51 63 59 40 7 1 1 1 1 1 . 40 34 27 37 8 1 . 1 0 . 39 . 40 . . 9 1 1 1 0 0 84 40 42 . 33 10 1 . 1 1 . 29 32 42 55 52 ; run;

proc print; var id m_on m_off; run;

-- Lauren Haworth

[This followup was posted to comp.soft-sys.sas and a copy was sent to the cited author.]

In article <42775301@prancer.Dartmouth.EDU>, Haiyi.Xie@DARTMOUTH.EDU says... > Hi SAS experts: > > I need some help for the following programing problem: > > Data: > > id t1 t2 t3 t4 t5 m1 m2 m3 m4 m5 > > 1 1 1 1 1 1 44 28 38 30 31 > 2 1 0 1 0 0 69 50 74 65 . > 3 1 1 1 1 0 43 40 37 36 50 > 4 1 0 1 1 1 74 . 62 67 . > 5 1 1 0 0 0 45 38 . 43 44 > 6 1 0 0 1 0 56 51 63 59 40 > 7 1 1 1 1 1 . 40 34 27 37 > 8 1 . 1 0 . 39 . 40 . . > 9 1 1 1 0 0 84 40 42 . 33 > 10 1 . 1 1 . 29 32 42 55 52 > > > Data description: t1 - t5 are indicators, indicating whether > a patient is on medication from time1 to time5 (1=on, 0=off). > M1 - M5 are measures for health outcome in corresponding time periods. > > Task: to compare outcome when a patient is ON drug with > the outcome when he/she is the FIRST (immediately off the drug) > time OFF the drug. > > e.g., For patient 2, I need m1=69, m2=50 > For patient 3, I need m4=36, m5=50 > For patient 6, I need m1=56, m2=51 > For patient 8, I need m3=40, m4=. > patient 1 and 10 should be ignored as they have NO "off" period. > > Question: How can I program it to get the data I need? > > Thank you very much!! > > Haiyi >


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