11-29-2011 09:52 PM
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 ?
11-30-2011 04:00 AM
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.
11-30-2011 05:45 AM
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';