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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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