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