Hi, I have dataset as follows:
data have; input x $3. y $4.; datalines; yes no - yes yes ; run;
Using survey freq procedure,(proc surveyfreq) i am able to take the distribution of each variable. Missing category , is represented as space. Is anyway i can replace that space with the word "Missing" , to have something as follwos:
Table of x
Missing(not just space) 1 ....
no 1 ...
yes 2
Total 4
Thank you .
Your Have set has a value of a dash. Is that actually supposed to be there?
With SAS anytime the question involves "display a value" then Proc Format quite often has an answer and possibly the easiest:
Proc format; value $mymiss ' '='Missing'; run; proc freq data=have; tables x /missing; format x $mymiss.; run;
Since the underlying value is actually missing there are times you have to tell the Procedure that you want the missing included as a level of the variable in the results. In Surveyfreq this would be done on the Proc statement:
Proc surveyfreq data=have missing; tables x /; format x $mymiss.; run;
The format statement tells SAS to use the custom format for the variable.
If that dash is supposed to also represent missing you could modify the format to include the - as well:
Proc format; value $mymiss ' ' , '-' ='Missing'; run;
which would for report purposes treat the blank and the dash as missing.
Your Have set has a value of a dash. Is that actually supposed to be there?
With SAS anytime the question involves "display a value" then Proc Format quite often has an answer and possibly the easiest:
Proc format; value $mymiss ' '='Missing'; run; proc freq data=have; tables x /missing; format x $mymiss.; run;
Since the underlying value is actually missing there are times you have to tell the Procedure that you want the missing included as a level of the variable in the results. In Surveyfreq this would be done on the Proc statement:
Proc surveyfreq data=have missing; tables x /; format x $mymiss.; run;
The format statement tells SAS to use the custom format for the variable.
If that dash is supposed to also represent missing you could modify the format to include the - as well:
Proc format; value $mymiss ' ' , '-' ='Missing'; run;
which would for report purposes treat the blank and the dash as missing.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.