Thank you Linlin!
H, I agree with Tom, don't worry about it.
PG
Yah, everybody who's important ALREADY knows that PG is a genius!
Tom
While you could always extend the solution you have, here's another way:
data want;
if _n_=1 then do;
set have (where=(group=2) rename=(x1=x2 y1=y2));
set have (where=(group=6) rename=(x1=x3 y1=y3));
end;
set have;
run;
data have;
input Group : x1 y1;
cards;
1 3 5
2 6 5
3 1 2
4 0 4
5 1 7
6 7 1
7 2 9
;
data _null_;
set have(where=(group in (2,6)));
call symputx(cats('x_group',group),x1);
call symputx(cats('y_group',group),y1);
data want;
set have;
x2=&x_group2;
y2=&y_group2;
x3=&x_group6;
y3=&y_group6;
proc print;run;
Obs Group x1 y1 x2 y2 x3 y3
1 1 3 5 6 5 7 1
2 2 6 5 6 5 7 1
3 3 1 2 6 5 7 1
4 4 0 4 6 5 7 1
5 5 1 7 6 5 7 1
6 6 7 1 6 5 7 1
7 7 2 9 6 5 7 1
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.