I haven't used SAS in a while so this is probably a simple request, but I am having issues creating the dataset I want.
data have1;
input id group $;
cards;
1 a
1 b
1 c
;
run;
data have2;
input id samplevalue;
cards;
1 0.25
1 0.50
1 0.75
;
run;
data want;
input id samplevalue group $;
cards;
1 0.25 a
1 0.50 a
1 0.75 a
1 0.25 b
1 0.50 b
1 0.75 b
1 0.25 c
1 0.50 c
1 0.75 c
;
run;
Not the only way. Proc SQL will allow joins on multiple values of matching variables where a data step merge typically doesn't yield the result desired when there are multiples of BY variables in both data sets.
proc sql;
create table want as
select a.*,b.samplevalue
from have1 as a
full join
have2 as b
on a.id=b.id
order by a.id, a.group, b.samplevalue
;
quit;
Thank you so much, this is exactly what I needed and it works perfectly!
The 2025 SAS Hackathon Kicks Off on June 11!
Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.