BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sascode
Quartz | Level 8

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 .

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

2 REPLIES 2
ballardw
Super User

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.

sascode
Quartz | Level 8
It worked.
Thank you for your help.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 956 views
  • 0 likes
  • 2 in conversation