09-15-2015 04:47 AM
I have the following code. In the gender dataset created Sex variable is still being outputted as 1 or 2 instead of being Male /Female.
genderkey is a charecter variable
Please suggest me if i went wrong?
data test1(rename=(genderkey=start name=label));
set gender_dataset(keep=genderkey name);
proc format cntlin=test1;run;
START LABEL FMTNAME
1 Female genderfmt
2 Male genderfmt
09-15-2015 07:51 AM
I assume from what you have given that SEX is numeric, hence it will not map to the character format created by the read in. In test 1, convert genderkey to a number then it will create a number when read in as format. Currently 1 != "1". What you want is something like:
09-15-2015 11:28 AM
data test1; set gender_dataset; start = input(genderkey, best.); label = name; fmtname = 'genderfmt'; keep start label fmtname; run; proc format cntlin=test1; run; data gender; set have; Sex = put(genderkey, genderfmt.); run;