Function: CALL SORTC

Function That Sorts Character Values 

 

 Purpose: To sort the values of its character arguments in ascending order

  Syntax: CALL SORTC(<of> Char-1 <, … Char-n>)

                      Char-n is a character variable. If you use a variable list in the form
                      Var1–Varn, precede the list with the word "of"'.

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

 

     Examples
    
For these examples, c1='bad', c2='good', c3=' ', a1='b', a2='B',  a3='a', and a4='A'.
     Also, an array is defined as array chars[3] c1-c3

        Call Routine                                                       Return                  

CALL SORTC(of c1-c3)
CALL SORTC(of chars[*])
CALL SORTC(of a1-a4)

c1=' ', c2='bad', c3='good'
c1=' ', c2='bad', c3='good'
a1='A', a2='B', a3='a', a4='b'


Demonstrating the CALL SORTC routine

***Primary function: CALL SORTC;

data names;

input (Name1-Name5)(: $12.);

call sortc(of Name1-Name5);

datalines;

Charlie Able Hotel Golf Echo

Zemlachenko Cody Lane Lubsen Veneziale

bbb BBB aaa aaa ZZZ

;

title "Listing of data set NAMES";

proc print data=names noobs;

run;

Output

NB:

First of all, notice that the keyword "of" is needed, even though this CALL routine operates
on character values.
 The other feature to take note of is that alphabetic sorting is case
sensitive; the uppercase letters come before the lowercase letters in the collating sequence.


   

Comments

Popular posts from this blog

UPCASE, LOWCASE & PROPCASE

Function :MDY