Date: Mon, 6 Aug 2007 05:22:54 -0000
Reply-To: hary <hardik617@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: hary <hardik617@GMAIL.COM>
Subject: problem sorting dataset (selecting baseline lab value)
Content-Type: text/plain; charset="iso-8859-1"
I am trying to assign the baseline value of a lab to a variable called
Here is the dataset
input ptno labnm $ visitno labvalue;
1 ALB 1.00 0.3
1 ALB 1.01 0.2
1 ALB 1.02 .
1 ALB 1.03 0.4
1 ALB 2.00 0.2
1 ALB 2.01 .
1 ALB 2.02 .
1 ALB 2.03 .
In the above example for labtest ALB, for example the labvalue is 0.2
for visit 2. However the rule to select the baseline is as follows:
If there is a value for visit 2 then take this as baseline. however if
there is no value at visit 2 then take visit 2.01 as baseline, if we
do not have value at visit 2.01 then take 2.02 as baseline, if visit
2.02 value is missing take visit 2.03 as baseline. However if all the
visit 2,2.01,2.02,2.03 are missing then take visit 1.03 if not missing
as baseline, or else if everything including 2, 2.01,2.02,2.03,1.03 is
missing then take 1.02 visit value as baseline, or else if this is
missing too then take 1.01 as baseline or else if that is missing take
1.00 as baseline.
Can someone tell me how can i do that?
Thanks in advance.