BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cecily
Calcite | Level 5

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?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

2 REPLIES 2
ballardw
Super User

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.

cecily
Calcite | Level 5

thank you!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1178 views
  • 0 likes
  • 2 in conversation