BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MariaMTM
Calcite | Level 5

New SAS user, editing an existing (very experienced) user's program. Long story short, when I run the code below, the 'Other' category isn't being printed out, it's just being coded as Frequency Missing. How can I get it to be a value in the frequency table?

 

Relevant coding bits: 

Proc format;

VALUE $ZIPFMT ' 48021'='InCounty'
                              OTHER='OutCounty' ;

Data Students;
       Set &student;
       Format ZipCode $zipfmt.;

Title 'T16: Zip Code';
Proc Freq data=Students order=formatted;
Tables ZipCode;
run;
Title;

 

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Add missing to the FREQ statement and see if it shows up correctly.

 

Title 'T16: Zip Code';
Proc Freq data=Students order=formatted;
Tables ZipCode/missing;
run;
Title;

View solution in original post

4 REPLIES 4
Reeza
Super User

Add missing to the FREQ statement and see if it shows up correctly.

 

Title 'T16: Zip Code';
Proc Freq data=Students order=formatted;
Tables ZipCode/missing;
run;
Title;
Astounding
PROC Star

@Reeza has the right idea.  Prior to changing the code, however, you have to make a decision.  What should happen if ZipCode has a missing value?  Should it be counted in the "OutCounty" category, or should it display as missing (neither "InCounty" nor "OutCounty")?

 

The proposed solution places missing values in the "OutCounty" category.

MariaMTM
Calcite | Level 5

Thank you both so much. I've been trying to resolve this for hours. The code example provided works perfectly for me for this task, but what would I do differently if  *did* want OutCounty distinct from missing values?

 

 

 

 

Astounding
PROC Star

You would have to change the format definition.  It currently looks like this:

 

Proc format;

VALUE $ZIPFMT ' 48021'='InCounty'
                              OTHER='OutCounty' ;

 

You would need to add a  category:

 

Proc format;

VALUE $ZIPFMT ' 48021'='InCounty'

                              ' ' = 'Missing'
                              OTHER='OutCounty' ;

 

Make sure that OTHER= gets defined last.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 657 views
  • 5 likes
  • 3 in conversation