If that's not just an "academic" question then you will likely need to provide more information to get a suitable answer.
Please also provide a fully working data step that creates the have data and show us the desired result so we understand if that's about switching values between variables on a single row or if it is about swapping rows.
Variable swap:
data have;
infile datalines dlm=' ';
input var1-var5;
_v=var2;
var2=var4;
var4=_v;
drop _v;
Cards;
12 33 56 77 99
;
run;
proc print data=have;
run;
Row swap:
data have;
infile datalines dlm=' ';
input var @@;
Cards;
12 33 56 77 99
;
run;
data want;
do _i=1,4,3,2,5;
set have point=_i;
output;
end;
stop;
run;
proc print data=want;
run;
If that's not just an "academic" question then you will likely need to provide more information to get a suitable answer.
Please also provide a fully working data step that creates the have data and show us the desired result so we understand if that's about switching values between variables on a single row or if it is about swapping rows.
Variable swap:
data have;
infile datalines dlm=' ';
input var1-var5;
_v=var2;
var2=var4;
var4=_v;
drop _v;
Cards;
12 33 56 77 99
;
run;
proc print data=have;
run;
Row swap:
data have;
infile datalines dlm=' ';
input var @@;
Cards;
12 33 56 77 99
;
run;
data want;
do _i=1,4,3,2,5;
set have point=_i;
output;
end;
stop;
run;
proc print data=want;
run;
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.