I am trying to recode the missing frequency counts to unknown and have 0 missing and place them in the unknown category instead. My code does not produce errors but it does not recode them as unknown
I tried using if/then statements to recategorize
I am trying to recode the missing frequency counts to unknown and have 0 missing and place them in the unknown category instead. My code does not produce errors but it does not recode them as unknown
I tried using if/then statements to recategorize
Use the MISSING()
function to detect missing values.
if missing(gender) then gender='UNKNOWN';
This approach has problems though. If the recode value is longer than the variable, the recode value will be truncated.
If gender is $1, the assignment gender="UNKNOWN;
will yield gender = 'U'.
A better approach is to use a custom format to map the missing value to your indicator.
proc format;
value $missingc ' '='UNKNOWN';
value missingn . ='UNKNOWN';
run;
proc freq data=have;
table gender race ethnicity resident_or_staff age / missing;
format gender race ethnicity resident_or_staff $missingC.;
format age missingN.;
run;