hello,
If we have defined proc format for a character variable and if in proc format if we have not defined other value, it will default to "NA", correct ?
But we wanted to output all values where it is NA after applying format, how to do this ?
For ex - put(compress(sex),$gender.) if value from this function is NA, can we just output what ever value that came in for variable : sex ?
thanks!
If you have not defined an other category then the default is to echo the input.
proc format ;
value $gender 'M'='Male' 'F'='Female' other='NA';
run;
Actually I need something else, not the value NA.
Below code -
if Trim(put(compress(sex),$gender.)) eq 'NA' then gend_code = sex;
else gend_code= put(compress(sex),$gender.) ;
This is like sample code. I have something else actually with major percentage of records going to NA and for those records I wanted to input the value used in format originally with out using a lookuo value. In above case, when value = NA from put function, then use value in sex variable to gend_code.
Thanks!
As Tom said, when you do not define an OTHER= range
the default is to echo the input
just beware that the default length on output is not the input length but the widest string you have defined in your user format (or the value you can define with
value $gender(default=5) 'M'='Male' 'F'='Female' other='NA';
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.