It depends. How many variables do you have to do this for? How many different options....and most importantly, why?
Some applications require that you do this prior to your analysis for example, but SAS does not and can handle variables that are categorical in an analysis properly.
Some methods to fix this include:
- Using custom informats and re-read the dat from the text file as needed
- Using formats to remap the values to codes
- Apply formats, changes how the variables appear but not the underlying data itself. Usually this is done in reverse, values are stored as numerics but displayed as text with full descriptions. Helpful for ensuring no typos and that the order is as desired
- IF/THEN or SELECT statements to recode the values.
If you need to do the same remapping for multiple variables you may also want to use arrays.
Here's a tutorial on using Arrays in SAS
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/
@lawye010 wrote:
Hello,
This is probably a very basic question but I was handed a large dataset set that does not have the variables numerically coded. I have imported the file but would like to relabel the variables with numerical codes. For instance for sex, right now the categories are male and female but I would like male=0 and female=1. How would I code this? Thanks.