DATA Step, Macro, Functions and more

output for merge

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

output for merge

I want to create seperate outputs for if statement after merge

data final;
merge i301_302(in=a) inc1(in=b);
if a and not b then output i3012;
if b and not a then output i303;
by UPTID;
run;

 

Unfortunately this is not working. Can anyone help me if my datastep is wrong


Accepted Solutions
Solution
‎03-10-2017 08:05 AM
Super User
Posts: 5,518

Re: output for merge

[ Edited ]
Posted in reply to alexdsa310

This statement is wrong:

 

data final;

 

This tells SAS to create a data set named FINAL.  Later, you try to output observations into data sets that don't exist:  i3012 and i303.  The OUTPUT statements must reference data set names that appear on the DATA statement.  Most likely you need to change to:

 

data i3012 i303;

 

Also note, your logic will not observations that match.  For any UPTID values that appear in both data sets, they do not get output at all.

View solution in original post


All Replies
Solution
‎03-10-2017 08:05 AM
Super User
Posts: 5,518

Re: output for merge

[ Edited ]
Posted in reply to alexdsa310

This statement is wrong:

 

data final;

 

This tells SAS to create a data set named FINAL.  Later, you try to output observations into data sets that don't exist:  i3012 and i303.  The OUTPUT statements must reference data set names that appear on the DATA statement.  Most likely you need to change to:

 

data i3012 i303;

 

Also note, your logic will not observations that match.  For any UPTID values that appear in both data sets, they do not get output at all.

Super User
Posts: 7,866

Re: output for merge

Posted in reply to alexdsa310

Read the log, it says it all:

ERROR 455-185: Data set was not specified on the DATA statement.

You can only output to datasets that have been specified in the data statement.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 218 views
  • 2 likes
  • 3 in conversation