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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.