@Tom Of course you are right.
Something like this would work
data combine;
length identifier $20;
identifier = ' ' ;
set get_test1_nodup
get_test2_nodup ;
if identifier ='' then identifier=Spot_2||Spot_4||Spot_3;
run;
but is is not shorter or clearer than @mkeintz 's proposal.
I was keen to emphasize that variables could be processed at the top of the data step, before the SET statement is encountered, but my example fell flat on its face...
"There's more than one way to skin a cat". So here's another way. It has no explicit output and no call missing. But it does take advantage of a DROP= parameter and conditional SET statement. And it eliminates the unintended carry forward of stay stale identifier values.
data combine;
set get_test1_nodup
get_test2_nodup (drop=identifier in=in2);
identifier=Spot_2||Spot_4||Spot_3;
if in2 then set get_test2_nodup;
run;
The crucial point here is that the conditional SET is explicitly synchronized with reading data from get_test2_nodup in the unconditional SET.
Thank you everyone for the replies -- this was very educational.
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.