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
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.