DATA Step, Macro, Functions and more

call sortc or sortn

Accepted Solution Solved
Reply
Super Contributor
Posts: 284
Accepted Solution

call sortc or sortn

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;

 

 


Accepted Solutions
Solution
‎09-11-2017 05:57 PM
Super User
Posts: 13,084

Re: call sortc or sortn

Posted in reply to SAS_inquisitive

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


All Replies
Super User
Posts: 22,874

Re: call sortc or sortn

Posted in reply to SAS_inquisitive

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.  

PROC Star
Posts: 1,356

Re: call sortc or sortn

@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.
Super Contributor
Posts: 284

Re: call sortc or sortn

Posted in reply to novinosrin
@novinosorin I have much more SAS books than you can think of. I, sometimes, post questions for the benefit of others too.
PROC Star
Posts: 1,356

Re: call sortc or sortn

Posted in reply to SAS_inquisitive

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

Super Contributor
Posts: 284

Re: call sortc or sortn

Posted in reply to novinosrin

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

Solution
‎09-11-2017 05:57 PM
Super User
Posts: 13,084

Re: call sortc or sortn

Posted in reply to SAS_inquisitive

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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