I'm having trouble inputting recid data into SAS. Here is my first 10 lines of code:
data recid;
input id$ week arrest$ fin$ age race$ wexp$ mar$ paro$ prio educ$;
cards;
1 20 1 0 27 1 0 0 1 3 3
2 17 1 0 18 1 0 0 1 8 4
3 25 1 0 19 0 1 0 1 13 3
4 53 0 1 23 1 1 1 1 1 5
5 53 0 0 19 0 1 0 1 3 3
6 53 0 0 24 1 1 0 0 2 4
7 23 1 0 25 1 1 1 1 0 4
8 53 0 1 21 1 1 0 1 4 3
9 53 0 0 22 1 0 0 0 6 3
10 53 0 0 20 1 1 0 0 0 5
;
run;
The output, however, ends up looking like this
id week arrest fin age race wexp mar paro prio educ
1 1 20 1 0 27 1 0 0 1 3 3 2 17 1 01
What's going on here?
Categorical doesn't mean they need to be character.
In fact, if you want them to sort and have them as a character, it'll sort alphabetically, ie 1, 10, 11, 12 while numbers will sort correctly.
You can use formats to apply any descriptive labels and the CLASS statement will take both numeric/character variables when you need to specify variables as categorical.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.