how we change the format like
gender 0,1
to gender
0=male
1=female
how we change the format
for gender
0=male
1=female
It's always a very good idea to provide usable test/example data (in a data step with datalines, see my footnotes for converting existing data to such a step, and how to post it).
So I have to guess that you have a numeric variable that only contains ones and zeroes.
Create a value format with proc format:
proc format lib=work;
value gender
0 = 'male'
1 = 'female"
;
run;
Then you can use that format, eg by assigning in a data step, or with proc print:
proc print data=have;
format sex gender.;
run;
Hi,
If we take an example of class dataset...
Proc sql;
create table class1 as
Select name,
case when sex='M' then 0 else 1 end as Sex ,
age,height,weight from sashelp.class;
Quit;
And vice versa..
Or if you don't want formats:
data want; set have; length genderc $20; if gender=0 then genderc="male"; if gender=1 then genderc="female"; run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.