A simple question
I have a dataset containing a variable 'Sex', with values 1 and 2 (this is a numerical variable)
I want to change the contents of the variable to Female if Sex=1 and Male if Sex =2.
So the type of the variable will need to be changed too
Any simple way of doing it (without creating a temporary dummy variable?)
Best wishes
It is the way mentioned in sas doc
Sample 24590: Convert values from character to numeric or from numeric to character
may i ask what is the problem with this way?
You can do the convert also in PROC SQL
check this old thread
Not sure of your question.
Do you want a solution like this?
proc format;
value num2ch 1 = 'Female'
2 = 'Male'
;
run;
data have;
input Sex;
datalines;
1
1
2
2
1
2
;
run;
data want;
set have;
format Sex num2ch.
run;
proc print data = want;
run;
proc contents data = want;
run;
But the type of SEX is still Number in WANT data set.
Not really without temporary variables.
You can use a format to change the display, depending on what you're doing, a Class statement in many procs will accomplish this automatically.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.