DATA Step, Macro, Functions and more

Data ...; merge dataset1 (in=a) dataset2 (in=b) ...

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Data ...; merge dataset1 (in=a) dataset2 (in=b) ...

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!


Accepted Solutions
Solution
3 weeks ago
SAS Super FREQ
Posts: 295

Re: Data ...; merge dataset1 (in=a) dataset2 (in=b) ...

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


All Replies
Solution
3 weeks ago
SAS Super FREQ
Posts: 295

Re: Data ...; merge dataset1 (in=a) dataset2 (in=b) ...

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.

 

Super User
Posts: 19,815

Re: Data ...; merge dataset1 (in=a) dataset2 (in=b) ...

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...

Super User
Posts: 11,343

Re: Data ...; merge dataset1 (in=a) dataset2 (in=b) ...


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

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 117 views
  • 2 likes
  • 4 in conversation