Hi,
I have created the following temporary "sorted" dataset. Would it be possible to provide me with code so that the variables within each observation are in ascending order (example output below)? Thanks!
Code
data sorted;
input var1-var6;
datalines;
23 2 43 55 1 6
132 3 23 67 45 2
11 99 101 24 96 44
44 1 1276 1734 1599 1921
;
run;
Output wanted
Obs var1 var 2 var3 var4 var5 var6
1 1 2 6 23 43 55
2 2 3 23 45 67 132
3 1 24 44 96 99 101
4 1 44 1276 1599 1734 1921
CALL SORTN.
data sorted;
input var1-var6;
call sortn(of var1-var6);
[rest of your code]
run;
@jeremy4 wrote:
Hi,
I have created the following temporary "sorted" dataset. Would it be possible to provide me with code so that the variables within each observation are in ascending order (example output below)? Thanks!
Code
data sorted;
input var1-var6;
datalines;
23 2 43 55 1 6
132 3 23 67 45 2
11 99 101 24 96 44
44 1 1276 1734 1599 1921
;
run;
Output wanted
Obs var1 var 2 var3 var4 var5 var6
1 1 2 6 23 43 55
2 2 3 23 45 67 132
3 1 24 44 96 99 101
4 1 44 1276 1599 1734 1921
CALL SORTN.
data sorted;
input var1-var6;
call sortn(of var1-var6);
[rest of your code]
run;
@jeremy4 wrote:
Hi,
I have created the following temporary "sorted" dataset. Would it be possible to provide me with code so that the variables within each observation are in ascending order (example output below)? Thanks!
Code
data sorted;
input var1-var6;
datalines;
23 2 43 55 1 6
132 3 23 67 45 2
11 99 101 24 96 44
44 1 1276 1734 1599 1921
;
run;
Output wanted
Obs var1 var 2 var3 var4 var5 var6
1 1 2 6 23 43 55
2 2 3 23 45 67 132
3 1 24 44 96 99 101
4 1 44 1276 1599 1734 1921
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.