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 (September 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 9 Sep 2008 06:11:25 -0700
Reply-To:     pausha <pausha1@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         pausha <pausha1@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: Alternate for retain
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

Thanks for all your ideas..................That was right I gave a sample data I should have been more clear Okay .........It slike this

Every subjects have 10 to 12 visits its for every 8 week once and they are dosed. After week 52 they may or maynot have change in dose,for those who have change in dose we flag them'Yes' its one record/subject.For those who still continue the same dose is given a 'No' flag hope i made it clear. Data_null I liked your way infact i tired doing the same way..............

So my question is if in case like this where we have 10 to 12 records for same subjects to collapse them to one for a condition is retain and dow do until the only way or is there any other way even using SQL.

Thanks you all.

On Sep 8, 3:17 pm, mlhow...@avalon.net (Mary) wrote: > This works, but the user would still have to clarify what to do with data > like this: > > 008 week 48 20mg > 008 week 53 60mg > 008 week 54 60mg > 008 week 55 60mg > > This would flag these observations at 0, and the question would be what > would be considere the base value- is is the value at the end of the year, > or if there isn't one exactly at 52 weeks, would it be the one just previous > to the 52 week cutoff or the one after? (Note this is the same user that was > asking to carry forward values in rows (copy a row) a few weeks ago). > > My feeling (which is a field-specific one, I did pharmacy information > systems for 5 years) would be to carry forward the 20mg from week 48 to week > 52, making the base value to compare 20mg (and therefore there would be an > increase), but that is a user specification problem, not a programming > problem, the user needs to verify with us what they would want in the above > situation. > > -Mary > > > > ----- Original Message ----- > From: ./ ADD NAME=Data _null_, > To: SA...@LISTSERV.UGA.EDU > Sent: Monday, September 08, 2008 1:35 PM > Subject: Re: Alternate for retain > > Yes I see. I had added SUB 4 to test last record was Week 52 but that > broke everything. This may be better. Note added test cases. > > data likeThis; > input sub:$3. visit &$10. dose:$4.; > cards; > 001 week 50 30mg > 001 week 51 60mg > 001 week 76 60mg > 001 week 80 60mg > 002 week 35 30mg > 002 week 52 60mg > 002 week 58 90mg > 003 week 51 30mg > 003 week 52 60mg > 003 week 76 50mg > 003 week 80 60mg > 004 week 51 30mg > 004 week 52 60mg > 005 week 51 30mg > 005 week 52 60mg > 005 week 53 60mg > 005 week 54 60mg > 005 week 55 80mg > 005 week 56 80mg > 006 week 51 30mg > 006 week 52 60mg > 006 week 53 60mg > 006 week 54 60mg > 006 week 55 80mg > 007 week 51 60mg > 007 week 52 60mg > 007 week 53 60mg > 007 week 54 60mg > 007 week 55 80mg > ;;;; > run; > > data likeFlaged; > flag = 0; > do until(last.sub); > set likeThis; > by sub dose notsorted; > if visit ge 'week 52' then do; > if not flag > then flag = 1; > else flag = flag + first.dose; > end; > end; > flag = ifn(flag gt 1,1,0); > do until(last.sub); > set likeThis; > by sub; > output; > end; > run; > proc print; > id sub; > by sub; > run; > > On 9/8/08, snoopy369 <snoopy...@gmail.com> wrote: > > Hmm, rereading your post (my followup email didn't hit the listserv as > > I forgot to include that part correctly), I entirely misread the order > > of the set statement, so it's not that inefficient (though I still > > hold that it's likely the OP doesn't need it applied to every single > > record, but that's up to the OP to decide of course, and thus > > inefficient for that purpose), but you have some issues with your > > code: > > > If you include: > > data likeThis; > > input sub:$3. visit &$10. dose:$4.; > > cards; > > 001 week 50 30mg > > 001 week 51 60mg > > 001 week 76 60mg > > 001 week 80 60mg > > 002 week 35 30mg > > 002 week 52 60mg > > 002 week 58 90mg > > 003 week 51 30mg > > 003 week 52 60mg > > 003 week 76 50mg > > 003 week 80 60mg > > 004 week 51 30mg > > 004 week 52 60mg > > 004 week 53 60mg > > 004 week 54 60mg > > 004 week 55 80mg > > 004 week 56 80mg > > ;;;; > > run; > > as datacards, your sub 004 does not show up as flagged, when it > > should, because it has multiple weeks at each dosage level. I think > > if you modify the criteria to: > > if visit ge 'week 52' and (first.dose) /* and not first.sub */ then > > flag=1; > > again with the 'optional' first.sub - since it's unclear if it's > > possible for someone to have a week 53 start (or if they are relative- > > to-sub weeks), and unclear if it's desired for it to count as a > > change. I might be misunderstanding your reasoning for putting it > > that way, but it seems to work when I run that code anyhow. > > > -Joe > > > On Sep 8, 11:13 am, iebup...@GMAIL.COM ("./ ADD NAME=Data _null_,") > > wrote: > > > Snoopy, I thought your idea of using first and list was interesting > > > although I don't think you provided enough detail to actually achieve > > > the result. > > > > The OP did not like specify if like the FLAG was to like be applied to > > > like all observations for like each subject. I made like that > > > assumption. > > > > This looks like it works but should be check a bit more closely. > > > > data likeThis; > > > input sub:$3. visit &$10. dose:$4.; > > > cards; > > > 001 week 50 30mg > > > 001 week 51 60mg > > > 001 week 76 60mg > > > 001 week 80 60mg > > > 002 week 35 30mg > > > 002 week 52 60mg > > > 002 week 58 90mg > > > 003 week 51 30mg > > > 003 week 52 60mg > > > 003 week 76 50mg > > > 003 week 80 60mg > > > 004 week 51 30mg > > > 004 week 52 60mg > > > ;;;; > > > run; > > > > data likeFlaged; > > > flag = 0; > > > do until(last.sub); > > > set likeThis; > > > by sub dose notsorted; > > > if visit ge 'week 52' and (first.dose and last.dose) and not > > > last.sub then flag=1; > > > end; > > > do until(last.sub); > > > set likeThis; > > > by sub; > > > output; > > > end; > > > run; > > > proc print; > > > run; > > > > On 9/8/08, snoopy...@gmail.com <snoopy...@gmail.com> wrote: > > > > > On Sep 8, 10:17 am, pausha <paus...@gmail.com> wrote: > > > > > i have this dataset its clinical > > > > > > which has like 100 week visit and it slike for every 8 weeks my nee > > > > > dis i have to put a flag for subject who have switched in dose > > > > > after > > > > > week 52. > > > > > the scenario is they could have switched dose even before week 52 > > > > > but > > > > > i have to consider only afetr week 52 > > > > > dataset is like > > > > > sub visit dose > > > > > 001 week 50 30mg > > > > > 001 week 51 60mg > > > > > 001 week 76 60mg > > > > > 001 week 80 60mg > > > > > > in this case his flag should be 'No' because his change is not after > > > > > week 52 > > > > > > sub visit dose > > > > > 002 week 35 30mg > > > > > 002 week 52 60mg > > > > > 002 week 58 90mg > > > > > > in this case his flag is 'Yes' because his dose had incresed from 60 > > > > > to 90 after week 52 > > > > > > each subjec have like 10 records so i need to use anythinng other > > > > > than > > > > > reatin and first.sub > > > > > > any different ideas appreciated for this look check and flagging. > > > > > Thanks > > > > > Sounds like the easiest way to do this is (assuming 'visits' is the > > > > dataset above): > > > > > proc sort data=visits; by sub visit dose; run; > > > > data flags; > > > > set visits; > > > > by sub visit dose; > > > > if first.dose /* and not first.sub */ and visit > 52 then flag = > > > > "yes"; *this assumes visit is a numeric field, you need to use substr > > > > or whatever if it actually contains "week 52"; > > > > run; > > > > with optionally a check for first.sub if you want to not flag people > > > > whose first visit was after week 52 (if that's possible in your > > > > study), as they'd flag on their first dose without that check. I > > > > don't think a retain would be necessary.- Hide quoted text - > > - Show quoted text -


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