BookmarkSubscribeRSS Feed
sanyam13
Fluorite | Level 6

Name EmpID
---- -----
Jill 1864
Jack 2121
Joan 4698
John 5463


Given the SAS data set WORK.EMP_DEPT:
EmpID Department
----- ----------
2121 Accounting
3567 Finance
4698 Marketing
5463 Accounting


The following program is submitted:


data WORK.ALL;
merge WORK.EMP_NAME(in=Emp_N)
WORK.EMP_DEPT(in=Emp_D);
by Empid;
if (Emp_N and not Emp_D) or (Emp_D and not Emp_N);

run

 

can somebody plz how i m getting 2 observations in work.all data set , how this if condition is selecting the data .

2 REPLIES 2
SuzanneDorinski
Lapis Lazuli | Level 10

The if (Emp_N and not Emp_D) gets the rows in the EMP_NAME data set that are not in the EMP_DEPT data set.  There's one: Jill.

 

The if (Emp_D and not Emp_N) gets the rows in the EMP_DEPT data set that are not in the EMP_NAME data set.  There's one:  The empID 3567 in Finance.

 

The OR means that you want the rows that are in one data set but not the other, so you have 2 observations in the ALL data set.  

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1012 views
  • 2 likes
  • 3 in conversation