BookmarkSubscribeRSS Feed
Job04
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

4 REPLIES 4
ballardw
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.

 

Job04
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. 

ballardw
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.

PaigeMiller
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

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1178 views
  • 2 likes
  • 3 in conversation