I hope I have understood your problem correctly. I have slightly modified the code.
*** Input Sample cholesterol data;
***subject=patient number,sampdate=lab sample date,
***HDL=HDL,LDL=LDL,TRIG=Triglycerides.;
data cholesterol_base;
input subject $ sampdate date9. hdl ldl trig;
cards;
101 05sep2003 48 188 108
101 06sep2003 49 185 .
102 01oct2003 54 200 350
102 02oct2003 52 . 360
103 10nov2003 . 240 900
103 11nov2003 30 . 880
103 12nov2003 32 . .
103 13nov2003 35 289 930
;
run;
***input sample pill dosing date;
***subject=patient number,dosedate=drug dosing date;
data dosing;
input subject $ dosedate date9.;
cards;
101 07sep2003
102 07oct2003
103 13nov2003
;
run;
*** sorting cholesterol data for merging with dosing data;
proc sort data=cholesterol_base;
by subject sampdate;
run;
***sorting dosing data for merging with cholesterol data.;
proc sort data=dosing;
by subject;
run;
***DEFINE BASELINE HDL,LDL,TRIG VARIABLES.;
data baseline(rename=(hdl=b_hdl ldl=b_ldl trig=b_trig));
merge cholesterol_base dosing;
by subject;
keep subject sampdate dosedate hdl ldl trig;
run;
proc print data=baseline;
run;
proc sort data=baseline;
by subject sampdate;
run;
Message was edited by: Sandeep
Message was edited by: Sandeep