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
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.
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.