HomeContact
Base SAS
Default Sorting Order of Characters in SAS
Subhro Kar
Subhro Kar
January 12, 2021
1 min

Table Of Contents

01
Sorting Orders for Numeric Variables
02
Sorting Orders for Character Variables
Default Sorting Order of Characters in SAS

Sorting Orders for Numeric Variables

Numeric variables are sorted from the smallest-to-largest comparison, and the sequence is below.

  • SAS System missing values (shown as a period or special missing value)
  • negative numeric values
  • zero
  • positive numeric values.

Sorting Orders for Character Variables

PROC SORT uses either the EBCDIC or the ASCII collating sequence when it compares character values, depending on the environment under which the procedure is running.

In the EBCDIC sequence, lowercase characters are sorted first, followed by upper characters and then the digits. Note that some special characters interrupt the alphabetic sequences. The blank is the smallest displayable character.

Actual Number in ASCII sorting SequenceCharacters
#032 
#033!
#034 
#035#
#036$
#037%
#038&
#039 
#040(
#041)
#042*
#043+
#044,
#045-
#046.
#047/
#0480
#0491
#0502
#0513
#0524
#0535
#0546
#0557
#0568
#0579
#058:
#059;
#060<
#061\=
#062>
#063?
#064@
#065A
#066B
#067C
#068D
#069E
#070F
#071G
#072H
#073I
#074J
#075K
#076L
#077M
#078N
#079O
#080P
#081Q
#082R
#083S
#084T
#085U
#086V
#087W
#088X
#089Y
#090Z
#091[
#092\
#093]
#094^
#095_
#096`
#097a
#098b
#099c
#100d
#101e
#102f
#103g
#104h
#105i
#106j
#107k
#108l
#109m
#110n
#111o
#112p
#113q
#115s
#116t
#117u
#118v
#119w
#120x
#121y
#122z
#123{
#124
#125}
#126~

Share


Related Posts

Data Cleaning in SAS: A Complete Guide with Examples
December 19, 2024
2 min
© 2025 9to5sas
AboutContactPrivacyTerms