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-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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