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
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;
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;
@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.
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?
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.