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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Registration is open
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss. Register now and lock in 2025 pricing—just $495!