BookmarkSubscribeRSS Feed
Cecillia_Mao
Obsidian | Level 7

Hi everybody, I have a question regarding ORDER=FORMATTED: If no format is applied, the BEST12. format is used for numeric variables. However, I haven't found any description for categorical variables.

 

I tested using sashelp.cars dataset. It seems like the order is the same as the result of order=internal. So my question is if no format is specified for order=formatted, does SAS use order=internal instead?

 

proc report data=sashelp.cars(OBS=30);
Column Type invoice ;
define type/order order=formatted;
run;

 

proc report data=sashelp.cars(OBS=30);
Column Type invoice ;
define type/order order=internal;
run;

 

 

Thanks for your help in advance! Any thoughts would be appreciated!

 

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

If there is no format associated, the value is used, which is what option internal does.

 

Cecillia_Mao
Obsidian | Level 7

Thanks so much for confirming!

ballardw
Super User

If by "categorical" you mean Character then the format will be $W.  Which will generally mean your national language sort setting. Note that you may get some things that appear out of order if they have leading spaces because the sort will use the space for determining order but the display in many procedures will not display the leading space.

 

Numerical variables can be used as categorical. Custom formats to create groups of values, such as 10-year intervals for age, can turn continuous values into categorical values for most analysis, reporting graphing procedures.

 

Cecillia_Mao
Obsidian | Level 7
Thanks so much for the comments! I just learned that most procedures won't display leading spaces. Regarding order=formatted, If there is no specified format, it will use best12. format for numerical variable and $w. format for categorical variables. And the order for those formats still follow 1-9, A-Z, a-z order.
Thank you!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 819 views
  • 1 like
  • 3 in conversation