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!
SAS Innovate 2025: Register Now
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9. Sign up by Dec. 31 to get the 2024 rate of just $495. Register now!