BookmarkSubscribeRSS Feed
Quartz | Level 8

I have categorical  variable ( string variable) with 3 levels: one, two and three. I would like to  recode this variable to have these levels as 1, 2 and 3.  Thank you

Super User

How do you want to use the variable? Are you wanting a numeric value or are you asking for IF/Then/Else type code to reassign values of the existing variable?



I ask because a SAS Format is a typical way to change displayed values without changing data which is sometimes more flexible and quicker than actually changing values. But display order is not always as expected depending on the procedures used.


Quartz | Level 8

Variable will be used in certain model as predictor. Actually I run the model using the original variable and I got weird results. So I want to recode  the variable  either by creating new variable or just replacing it. 

Super User

You might be better showing the code for the model and the results that you think are weird, describing in what way they are "weird".


I have a hard time thinking of a true categorical variable that changing the coding in a one-to-one fashion would affect the model.

Diamond | Level 26

Recoding your strings to 1 2 3 does not change the model. It is a waste of time in modeling.

Paige Miller


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
  • 3 in conversation