SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cdubs
Quartz | Level 8

I'm trying to understand the following code: 

 

data final_eligibilityfile (drop=dtstart);
		merge eligibility_2 (in=a) status (in=b) county (in=c) ;
		by PID starting ending;
		if a;
run;

Two questions: 

- What is the purpose of (in=b) and (in=c) if we don't reference b or c later on in the code (?) (as far as I'm aware)

- What does the "if a" mean? Does that mean if a given variable is in a (e.g. "eligibility_2")? 

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenKuhfeld
Ammonite | Level 13

in= variable creates a binary variable that tells you if that input data set contributes to this observation.  Correct--if you don't use them, there is no point in making them.


The IF statement is a subsetting IF.  If the variable is true (1 in this case) processing is continued and the observation is output.

 

The code is keeping all observations that come at least in part from the eligibility_2 data set.

 

View solution in original post

3 REPLIES 3
WarrenKuhfeld
Ammonite | Level 13

in= variable creates a binary variable that tells you if that input data set contributes to this observation.  Correct--if you don't use them, there is no point in making them.


The IF statement is a subsetting IF.  If the variable is true (1 in this case) processing is continued and the observation is output.

 

The code is keeping all observations that come at least in part from the eligibility_2 data set.

 

Reeza
Super User

IN= Data Set Option

Creates a Boolean variable that indicates whether the data set contributed data to the current observation.

 

https://support.sas.com/documentation/cdl/en/ledsoptsref/69751/HTML/default/viewer.htm#n1p1o2dsuc465...

ballardw
Super User

@cdubs wrote:

I'm trying to understand the following code: 

 

data final_eligibilityfile (drop=dtstart);
		merge eligibility_2 (in=a) status (in=b) county (in=c) ;
		by PID starting ending;
		if a;
run;

Two questions: 

- What is the purpose of (in=b) and (in=c) if we don't reference b or c later on in the code (?) (as far as I'm aware)

- What does the "if a" mean? Does that mean if a given variable is in a (e.g. "eligibility_2")? 

 

Thank you!


 

Perhaps you should investigate the free online courses and tutorials at https://support.sas.com/edu/elearning.html?ctry=us&productType=library

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 74645 views
  • 4 likes
  • 4 in conversation