data labs;
input subject $ lab_test $ lab_date lab_result;
datalines;
101 HGB 999 1.0
101 HGB 1000 1.1
101 HGB 1011 1.2
101 HGB 1029 1.3
101 HGB 1030 1.4
101 HGB 1031 1.5
101 HGB 1058 1.6
101 HGB 1064 1.7
101 HGB 1725 1.8
101 HGB 1735 1.9
;
run;
**** INPUT SAMPLE DOSING DATE.
**** SUBJECT = PATIENT NUMBER, DOSE_DATE = DATE OF DOSING.;
data dosing;
input subject $ dose_date;
datalines;
101 1001
;
run;
**** SORT LAB DATA FOR MERGE WITH DOSING;
proc sort
data = labs;
by subject;
run;
**** SORT DOSING DATA FOR MERGE WITH LABS.;
proc sort
data = dosing;
by subject;
run;
**** MERGE LAB DATA WITH DOSING DATE. CALCULATE STUDY DAY AND
**** DEFINE VISIT WINDOWS BASED ON STUDY DAY.;
/*labdate=event date dosedate=intervation */
data labs_new1;
merge labs(in = inlab)
dosing(keep = subject dose_date);
by subject;
**** KEEP RECORD IF IN LAB AND RESULT IS NOT MISSING.;
if inlab and lab_result ne .;
**** CALCULATE STUDY DAY.;
if lab_date < dose_date then
study_day = lab_date - dose_date;
else if lab_date >= dose_date then
study_day = lab_date - dose_date + 1;
**** SET VISIT WINDOWS AND TARGET DAY AS THE MIDDLE OF THE
**** WINDOW.;
if . < study_day < 0 then
target = 0;
else if 25 <= study_day <=35 then
target = 30;
else if 55 <= study_day <= 65 then
target = 60;
else if 350 <= study_day <= 380 then
target = 365;
else if 715 <= study_day <= 745 then
target = 730;
**** CALCULATE OBSERVATION DISTANCE FROM TARGET AND
**** ABSOLUTE VALUE OF THAT DIFFERENCE.;
difference = study_day - target;
absdifference = abs(difference);
run;
My question is what is the meaning of in=inlab?
since I didnot find inlab variable in the labs data set....so why here there exists in=inlab?
The option IN= creates a temporary variable that is set to 1 when the values of that record are from the specified data set.
The temporary variables can then be referenced for any conditional processing based on data set membership.
The variable is NOT added to any output.
The option IN= creates a temporary variable that is set to 1 when the values of that record are from the specified data set.
The temporary variables can then be referenced for any conditional processing based on data set membership.
The variable is NOT added to any output.
thank you!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.