Hi all,
I have a dataset that I am creating many tables from, and I would like to continually print the level "Other" as the bottom of the otherwise-alphabetized levels of the character variable. What is the easiest way to do this so that "Other" is always printed last? My current solution is to use "zOther" as the level, but that is suboptimal. I could also create this as a numeric variable with labels rather than as a character variable -- is that the preferred way?
Thanks.
Are these values character, numeric with a format displaying "Other" or both?
If you have existing formats for any of these variables you should share those as well as some example data values to test with (best provided as data step code).
Hi @qwertyzx and welcome to the SAS Support Communities!
@qwertyzx wrote:
I could also create this as a numeric variable with labels rather than as a character variable -- is that the preferred way?
In my experience this is the most common approach to this problem. In PROC FREQ (and several other procedures) you can use the ORDER= option to control the order of levels. But not all of the four values of this option are equally suitable:
If a procedure has a different default of the ORDER= option (e.g., PROC REPORT uses ORDER=FORMATTED), just specify ORDER=INTERNAL where appropriate.
As mentioned, the internal values can be either numeric or character, but the (alphabetical) sort order of character variables has its pitfalls (e.g., "2">"10") so that numeric values (preferably integers) are often easier to use.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.