Hello!
I am trying to look at the number of asthma counts by zip code, but when I run the proc freq statement, the zip codes with zero counts of asthma do show up in the results viewer. How can I fix this? Example code below. I have already tried putting 'missing' at the end of the tables step.
proc freq data=work.datarequest;
tables zipcode*ASTHMA / norow nocol nopercent;
where ASTHMA=1;
run;
Don't use the WHERE statement. That will prevent PROC FREQ from ever seeing the zipcodes that never have ASTHMA=1.
Ideally, I wanted to keep the where statement so I do not have to format the data as much. Since I am only interested in Asthma cases.
I cannot visualize what you are trying to do. Can you provide input data and expected results. Just enough data so it demonstrates the issue.
Probably PROC FREQ is not the right tool. For example PROC SUMMARY (aka MEANS) has methods to allow you to provide information on the complete list of possible values.
Here is some sample data. For these data, the PROC FREQ step shows only the frequencies for ASTHMA=1. It does not show any cells for missing values.
data Have;
infile datalines missover;
input zipcode ASTHMA;
datalines;
12345 1
12345 1
12345 0
12345
52345 1
52345 1
52345 0
52345
52345 1
52345
65432 0
65432
;
proc freq data=Have;
tables zipcode*ASTHMA / norow nocol nopercent;
where ASTHMA=1;
run;
If this does not answer your question, please modify the input data to mimic the data that you have.
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.