Function: Call Sortn

 Function: Call Sortn

Purpose: To sort the values of its numeric argument in ascending order.

Syntax:  CALL SORTN(<of> Vaar-1 <,  ... Var-n>)

              Var-n  is a numeric variable. If you use a variable list in the form VAR1-Varn,                              precede  the list with the word "of".

              Arguments to the CALL SORTN routine cannot be constants. You may use  array                    references as   arguments to this routine as well (see the following examples)

  Examples
For these examples, x1=8, x2=2, x3=., x4=1, a=9, b=7, c=8.

Also, an array is defined as array nums[4] x1-x4;

     Call Routine                                          Returns
CALL SORTN(of x1-x4)                        x1=., x2=1, x3=2, x4=8
CALL SORTN(of nums[*])                        x1=., x2=1, x3=2, x4=8
CALL SORTN(a,b,c)                                 a=7, b=8, c=9
 
Program to grade quizzes, dropping the two lowest quiz
scores (using CALL SORTN)
  


 ***Primary function: CALL SORTN;
***Other function: MEAN;

data quiz_scores;
input Name : $15.Quiz1-Quiz10;
call sortn(of Quiz1-Quiz10);
Grade =
mean(of Quiz3-Quiz10);
datalines;
George 78 90 90 95 88 . 100 98 95 90
Susan 100 100 100 100 100 100 . . . .
Maxwell 50 50 90 90 95 88 87 86 84 90
;
title "Listing of data set QUIZ_SCORES";
proc print data=quiz_scores noobs heading=h;
run; 

Output


Comments

Popular posts from this blog

UPCASE, LOWCASE & PROPCASE

Function :MDY