BookmarkSubscribeRSS Feed
Billa
SAS Employee

Hi Experts,

 

I have a muldimensional array array_mult_zero_coupon[500,4] and I would like to sort it by a specific dimension/Column (example: by the second dimension).

 

Two Questions:

 1. Can I use Call Sortn() function in the Proc FCMP ? 

 

call sortn(of array_mult_zero_coupon[*]);
ERROR: Argument number 1 to the CALL subroutine SORTN must be a variable.

 

 2. Does anyone could give a example of how to sort an multidimensional/matrix array without call sort?

 

Regards,

2 REPLIES 2
ballardw
Super User

@Billa wrote:

Hi Experts,

 

I have a muldimensional array array_mult_zero_coupon[500,4] and I would like to sort it by a specific dimension/Column (example: by the second dimension).

 

Two Questions:

 1. Can I use Call Sortn() function in the Proc FCMP ? 

 

call sortn(of array_mult_zero_coupon[*]);
ERROR: Argument number 1 to the CALL subroutine SORTN must be a variable.

 

 2. Does anyone could give a example of how to sort an multidimensional/matrix array without call sort?

 

Regards,


When discussing errors it is always a good idea to include the entire proc or data step that generated the error from the log as well as all notes, warnings and errors. Best is to paste the text copied from the log into a code box opened with the forum's {I} icon to preserve formatting of messages.

 

I would suspect from the incomplete code that you have an issue with declaring the parameters for the function or subroutine that attempts to use call sortn.

 

 

KachiM
Rhodochrosite | Level 12

Billa:

 

Your Two Questions:

 1. Can I use Call Sortn() function in the Proc FCMP ? 

 

call sortn(of array_mult_zero_coupon[*]);
ERROR: Argument number 1 to the CALL subroutine SORTN must be a variable.

 

 2. Does anyone could give a example of how to sort an multidimensional/matrix array without call sort?

===========================

[1] Call SORTN() does not work in FCMP Environment. I confirm that I got the same ERROR as you have got. The OF operator within Call SORTN() is not working. So, sorting array within FCMP function has to depend on  an external sorting routine. Paul Dorfman gave a Quicksort Macro which can be adapted.

 

[2] I can provide an example. Do you want sorting on ALL Rows or Columns of the Data Set ? Or on a given Row / Column ? If you specify your requirements, I can give you a FCMP function example using a FCMP Sorting Routine.

 

Best regards,

 

DataSP

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 733 views
  • 1 like
  • 3 in conversation