Date: Tue, 6 Mar 2012 11:46:06 -0500
Reply-To: Thomas George <tgeorgeturutiyil@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Thomas George <tgeorgeturutiyil@GMAIL.COM>
Subject: Re: First. Last.
In-Reply-To: <A83AA17321E97F4C908B78096448816501A00D23@BY2PRD0410MB377.namprd04.prod.outlook.com>
Content-Type: text/plain; charset="us-ascii"
I wrote this code. I was wondering if there is a more efficient way of
writing this out. I wanted to use First.SP_vs_MD because it changes between
1 and 0. But it did not work out so i wrote it out this way. I changed the
response variable cos it is the same for station 2 to station 7 but not for
station 1.
data station1 (drop=Response_);
set station1;
Response=Response_;
run;
proc sort data = station1
out = station1;
by ID_No_ SP_vs_MD;
run;
Data station1md (drop = comments PRG Evaluation_Type Question_ SP_vs_MD
Response Out__Of ID);
set station1;
By ID_no_ ;
SP_MD = 1;
If question_ = "Q.1. Patients Needs & Feelings" then do;
Q1Resp = response;
Q1Out_of = Out__of;
end;
If question_ = "Q.2. Coherence" then do;
Q2Resp = response;
Q2Out_of = Out__of;
end;
If question_ = "Q.3. Verbal Expression" then do;
Q3Resp = response;
Q3Out_of = Out__of;
end;
If question_ = "Q.4. Non-Verbal Expression" then do;
Q4Resp = response;
Q4Out_of = Out__of;
end;
If question_ = "CanMEDs - Global Rating" then do;
Q5Resp = response;
Q5Out_of = Out__of;
end;
If question_ = "CanMEDs - Competency" then do;
Q6Resp = response_ ;
Q6Out_of = Out__of;
end;
if last.ID_no_ then output;
retain Q1Resp Q1Out_of Q2Resp Q2Out_of Q3Resp Q3Out_of Q4Resp Q4Out_of
Q5Resp Q5Out_of Q6Resp Q6Out_of;
run;
Data station1sp (drop = comments PRG Evaluation_Type Question_ SP_vs_MD
Response Out__Of ID);
set station1;
By ID_no_ ;
SP_MD = 0;
If question_ = "Q.2. Response to Feelings" then do;
Q1Resp = response;
Q1Out_of = Out__of;
end;
If question_ = "Q.3. Degree of Coherence" then do;
Q2Resp = response;
Q2Out_of = Out__of;
end;
If question_ = "Q.4. Verbal Expression" then do;
Q3Resp = response;
Q3Out_of = Out__of;
end;
If question_ = "Q.5. Non-Verbal Expression" then do;
Q4Resp = response;
Q4Out_of = Out__of;
end;
If question_ = "Q.1. Overall" then do;
Q5Resp = response;
Q5Out_of = Out__of;
end;
If question_ = "Q.6. Key Points" then do;
Q6Resp = response;
Q6Out_of = Out__of;
end;
if last.ID_no_ then output;
retain Q1Resp Q1Out_of Q2Resp Q2Out_of Q3Resp Q3Out_of Q4Resp Q4Out_of
Q5Resp Q5Out_of Q6Resp Q6Out_of;
run;
data station1modify;
set station1md station1sp;
run;
Also, how can i do this for all 7 stations instead of writing and copying
down the codes?
Thanks,
Thomas