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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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