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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: