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 (July 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 19 Jul 2010 11:24:00 -0700
Reply-To:   "Richard A. DeVenezia" <rdevenezia@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Richard A. DeVenezia" <rdevenezia@GMAIL.COM>
Subject:   Re: Data Logic
Content-Type:   text/plain; charset=ISO-8859-1

On Jul 16, 3:28 pm, Al <ali6...@gmail.com> wrote: > Dear All; > > This is what i have > > data have; > input pat meds $ stdt spdt; > > datalines; > 111 ABC 1 . > 111 CBF 1 140 > 111 DFS 141 170 > 111 NAT 65 . > 111 MAN 160 165 > 111 MAA 6 223 > ; > run; > > range for week 20 (1-143),week 24 (1-171),week 23 (1-227) and the > rules are > > if stdt = 1 and spdt = . then it should be counted under week20 , > week24 and week32 > > if stdt has started at week 20 and kept on progressing it has stopped > (spdt) he counted under week20,week24 and week32 > > if stdt has started at week 20 and stopped at week 24 it has to be > counted under week20,week24 > > and so on > > i know i am being very crude in explaining the issue here ,so here is > the graphical presentation > > pat med week20 > week24 week32 > (1-143) > (1-171) (1-227) > > 111 ABC > (1)------------------------------------------------------------------------­-------- > > 111 CBF (1)------------------->(140) > 111 DFS (141)------>170 > 111 NAT > (65)-----------------------------------------------------------------------­--- > > 111 MAN (160)------>(165) > > 111 MAA > (6)---------------------------------------------------------------- > > >(223) > > ideally ,output should like > > pat week20 week24 week32 > 111 5 4 3 > > Thanks in advance > Al

Al:

The explanation was pretty vague. Here is some sample code that matches your sample output/

---------- data have; input pat meds $ stdt spdt;

datalines; 111 ABC 1 . 111 CBF 1 140 111 DFS 141 170 111 NAT 65 . 111 MAN 160 165 111 MAA 6 223 ; run;

data activity; set have;

if STDT > 0; GUARD = MIN (SPDT,1e10); if STDT <= GUARD;

if ( STDT < 1 or 1 <= STDT <= 143 ) and (GUARD > 143 or 1 <= GUARD <= 143) then c143 = 1; if ( STDT < 144 or 144 <= STDT <= 171 ) and (GUARD > 171 or 144 <= GUARD <= 171) and c143 then c171 = 1; if ( STDT < 171 or 171 <= STDT <= 227 ) and (GUARD > 227 or 172 <= GUARD <= 227) and c171 then c227 = 1; run; ----------

Richard A. DeVenezia http://www.devenezia.com


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