BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SAS_inquisitive
Lapis Lazuli | Level 10

Hello,

How does CALL SORTC or CALL SORTN work?  Is it a horizontal sorting of the variables?

The following program does not seem to make any changes.

 

data test;
	set sashelp.class;
	call sortn (age, height);
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Compare the differences in Example and Example2 in the code below:

data example;
   input v1 v2 v3;
datalines;
1 2 3
3 1 2
27 18 4
;
run;

data example2;
   set example;
   call sortn (v1,v2,v3);
run;

View solution in original post

6 REPLIES 6
Reeza
Super User

@SAS_inquisitive wrote:

 

The following program does not seem to make any changes.



 

That's because age is always less than height anyways. Make a better examle where the order would change to test it properly.  

novinosrin
Tourmaline | Level 20

@SAS_inquisitive  Reeza rightly mentioned to work on better examples. My suggestion is, if you don't mind and can afford to buy a book, try to get this-

 

https://www.sas.com/store/prodBK_60864_en.html?storeCode=SAS_US&storeCode=SAS_US

 

Learning SAS® by Example: A Programmer's Guide

 
That has incredible and awesome examples on exactly what you are looking for. Also, you will start to contribute with your solutions very soon.
SAS_inquisitive
Lapis Lazuli | Level 10
@novinosorin I have much more SAS books than you can think of. I, sometimes, post questions for the benefit of others too.
novinosrin
Tourmaline | Level 20

Awesome, I wish I could have at least one. Please do post, I'll learn too.Thank you!

SAS_inquisitive
Lapis Lazuli | Level 10

This is learning and  knowledge sharing forum. One should take it easy to each other.

ballardw
Super User

Compare the differences in Example and Example2 in the code below:

data example;
   input v1 v2 v3;
datalines;
1 2 3
3 1 2
27 18 4
;
run;

data example2;
   set example;
   call sortn (v1,v2,v3);
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 3980 views
  • 2 likes
  • 4 in conversation