BookmarkSubscribeRSS Feed
deleted_user
Not applicable
the rest of the coding is ...

*** if labvalue is within 5 days of dosing,retain it as a valid baseline.;
if 1 <=(dosedate-sampdate)<=5 then
do i = 1 to 3 ;
if chol{i} ne . then
base{i} = chol{i};
end;
*** keep last record per patient holding the locf values.;
if last.subject;
label b_hdl="baseline hdl"
b_ldl="baseline ldl"
b_trig="baseline triglycerides";
run;

thanx
April.
6 REPLIES 6
deleted_user
Not applicable
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
deleted_user
Not applicable
*** Apply LOCF if the the value is within 5 days of dosing ***;
data locf;
set baseline;
by subject sampdate;
diff=dosedate-sampdate;
array base{3} b_hdl b_ldl b_trig;
array chol{3} hdl ldl trig;
retain hdl ldl trig;
do i=1 to 3;
if not(first.subject) and base{i}=. and 0 le diff le 5 then do;
chol{i} + base{i};
end;
else do;
chol{i} = base{i};
end;
end;
run; Message was edited by: Sandeep
deleted_user
Not applicable
I hope this will solve the problem. Message was edited by: Sandeep
deleted_user
Not applicable
Hi Sandeep..

thanx a lot for help.. n it actually produced an out put.
but it does not show the base line variables . it gives all the dates n values.

i want my report to look like this.

subject b_hdl b_ldl b_trig
101 49 185 108
102 52 . 360
103 32 240 880
so the final dataset produced will have a base line reading.. can u plz help again?
deleted_user
Not applicable
Hi there,

I believe that you are expecting a final dataset containg variables subject and the baseline values for three parameters on which LOCF is used and not the original baseline variables.
Do this:-
1) create a dataset by dropping b_hdl, b_ldl and b_trig
2) create one more datset by setting the dataset from step 1) and rename hdl, ldl and trig as b_hdl, b_ldl and b_tig respectively.

OR

Are you expecting, one record per subjects. If so, please check your baseline defination. Perform the above mentioned step and select the record as per the baseline defination.

Let me know if you still have questions further. :-) Message was edited by: Sandeep
1162
Calcite | Level 5
Try this:

***DEFINE BASELINE HDL,LDL,TRIG VARIABLES.;
data jessica.baseline;
merge jessica.cholesterol_base jessica.dosing;
by subject;
if dosedate - sampdate <= 5 and dosedate - sampdate > 0 then output;
run;

* This has to be a separate DATA step in order for the BY variable to work properly.;
data jessica.baseline;
set jessica.baseline;
by subject;
retain b_hdl b_ldl b_trig;
if first.subject then do;
b_hdl=.;
b_ldl=.;
b_trig=.;
end;
if hdl ne . then b_hdl = hdl;
if ldl ne . then b_ldl = ldl;
if trig ne . then b_trig = trig;
keep subject b_:;
if last.subject then output;
run;

proc print data=jessica.baseline;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 6 replies
  • 1145 views
  • 0 likes
  • 2 in conversation