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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.