Hello,
I know the order of simple numbers (for example: 3,9,18,21,48)
I know the order of alphabetic (for example: Luxury,Midsize,Sporty)
What is the rule to order char values : 18-19 ,19-21,21+?
What is the rule to order char values :Till 18, 18-19 ,19-21,21+?
May also explain why?
Character values are basically sorted according to the position of characters in the ASCII (Windows/UNIX) or EBCDIC (z/OS) table. But the sort order can be influenced by using alternate collating sequences for NLS support.
Hi @Ronein
The sorting depends on the variable type
Numeric variables are internally stored as double-precision float and are sorted on the numeric value, not on the digits you see.
Character values are sorted character by character (sort on first character, then second and so on..) on the decimal value of the character. All characters (digits, space, letters etc.) have a place in the latin- or utf8 or whatever-table and are sorted according to that.
What is the rule to order char values :Till 18, 18-19 ,19-21,21+?
From your earlier questions ... if the above is a formatted value of a numeric variable, you have the option in many SAS PROCs (such as PROC REPORT, PROC SUMMARY, PROC FREQ and probably many others) to sort these alphabetically based upon the formatted value, or to sort them numerically based upon the unformatted numbers. In general, it makes more sense to sort formatted values by the unformatted numbers, so 18 is always greater than "Till 18". PROC SORT will always use the UNFORMATTED values.
I found this document that can help to understand how sas sort char values
Character values are basically sorted according to the position of characters in the ASCII (Windows/UNIX) or EBCDIC (z/OS) table. But the sort order can be influenced by using alternate collating sequences for NLS support.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: