Date: Mon, 27 Aug 2007 16:56:15 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: Conditaional coding in data step
In-Reply-To: <BAY109-F222B607B548CF197AC7C48B2D20@phx.gbl>
Content-Type: text/plain; format=flowed
Suhong ,
What are your rules for assigning values to Variables (Question And
Response) ?
Toby Dunn
Two wrongs are only the beginning.
Success always occurs in private and failure in full view.
Experience is something you don't get until just after you need it.
From: Suhong Tong <sophidt@HOTMAIL.COM>
Reply-To: Suhong Tong <sophidt@HOTMAIL.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Conditaional coding in data step
Date: Mon, 27 Aug 2007 11:47:17 -0500
Hi Muthia,
Thanks for your response.
Here is want I want:
Obs id followup question response
1 1 1 LISTED 0
2 1 2 NOTYET .
3 1 3 NOTYET .
4 2 1 A
1
5 2 2 A
1
6 2 3 NOTYET .
7 3 1 A
1
8 3 2 A
2
9 3 3 A
1
10 4 1 MISSED .
11 4 2 MISSED .
12 4 3 A 1
I know that coding QUESTION on follow up 2 or 3 will be conditioned on
follow up 1 for ID1 and follow up 1 or 2 will depend on follow up 3 for ID4.
Since SAS works one row at a time, I don't know how to incorporate the
conditions that before or after the current row.
I hope someone can help me out on this and I believe there got to be a way
of doing it.
The steps I got to where I was:
proc sql;
create table peg as
select distinct id
from TST.qet
;
data imp;
set peg;
followup=1; output;
followup=2; output;
followup=3; output;
run;
data qet;
retain id followup question response;
length question $ 8;
set tst.qet;
if response=. then do;
question='LISTED';
response=0;
end;
run;
proc sort data=imp;
by id followup;
run;
proc sort data=qet;
by id followup;
run;
data pegus;
merge qet imp;
by id followup;
run;
>From: Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
>Reply-To: Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: Conditaional coding in data step
>Date: Mon, 27 Aug 2007 12:31:47 -0400
>
>Sophia,
>
>It may be helpful to give the desired output of the given sample data
>along
>with the steps to get them for someone to answer you.
>
>Muthia Kachirayan
>
>On 8/27/07, Sophia Tong <sophidt@hotmail.com> wrote:
> >
> > Dear list,
> >
> > I have a patient follow up data, wish to know who has been attempted to
> > reach, but failed, who had been reached and who had been reached and
>still
> > have follow up on the way.
> >
> > Below is my data:
> > The SAS System 09:25 Monday, August 27, 2007
>1
> >
> > Obs ID FOLLOWUP QUESTION RESPONSE
> >
> > 1 1 1 .
> > 2 2 1 A 1
> > 3 2 2 A 1
> > 4 3 1 A 1
> > 5 3 2 A 2
> > 6 3 3 A 1
> > 7 4 3 A 1
> >
> > and Here is how far I have got:
> > The SAS System 09:25 Monday, August 27, 2007 2
> >
> > Obs id followup question response
> >
> > 1 1 1 LISTED 0
> > 2 1 2 .
> > 3 1 3 .
> > 4 2 1 A 1
> > 5 2 2 A 1
> > 6 2 3 .
> > 7 3 1 A 1
> > 8 3 2 A 2
> > 9 3 3 A 1
> > 10 4 1 .
> > 11 4 2 .
> > 12 4 3 A 1
> >
> > I am having trouble to flag ID1, followup 2 and 3 as the follow ups yet
>to
> > come, and ID4 follow up 1 and 2 as missed calls. ID2 followup 3 would be
> > similar to ID1.
> >
> > I know the coding must be conditioning on all the follow ups, but don't
> > know how, tried something like the code below, but SAS won't take it.
> >
> > IF FOLLOWUP=1 AND ASSESSMENT_QUESTION_CD NE ' ' THEN DO;
> > IF ASSESSMENT_QUESTION_CD=' ' AND FOLLOWUP IN (2, 3) THEN
> > QUESTION='NOTYET';
> > END;
> > ELSE IF FOLLOWUP=2 AND ASSESSMENT_QUESTION_CD NE ' ' THEN DO;
> > IF FOLLOWUP=1 AND ASSESSMENT_QUESTION_CD = ' ' THEN QUESTION='MISSED';
> > IF FOLLOWUP=3 AND ASSESSMENT_QUESTION_CD = ' ' THEN QUESTION='NOTYET';
> > END;
> > ELSE IF FOLLOWUP=3 AND ASSESSMENT_QUESTION_CD NE ' ' THEN DO;
> > IF ASSESSMENT_QUESTION_CD=' ' AND FOLLOWUP IN (1, 2) THEN
> > QUESTION='MISSED';
> > END;
> > ELSE QUESTION=ASSESSMENT_QUESTION_CD;
> >
> > Please help me on this problem, many thanks in advance.
> >
> > Sophia
> >
_________________________________________________________________
Messenger Café — open for fun 24/7. Hot games, cool activities served daily.
Visit now. http://cafemessenger.com?ocid=TXT_TAGHM_AugHMtagline
_________________________________________________________________
Booking a flight? Know when to buy with airfare predictions on MSN Travel.
http://travel.msn.com/Articles/aboutfarecast.aspx&ocid=T001MSN25A07001