BookmarkSubscribeRSS Feed
GregBond
Obsidian | Level 7

I have data from a survey and would like the response options which ended up having a 0 count to be shown in the tables I made in proc freq.

Seems like a simple problem to fix, but i have yet to find a solution.

Thanks!

2 REPLIES 2
Reeza
Super User

If it appears in other fields you can try the sparse option.

proc freq data=have;

table question*answer/sparse;

run;

If it doesn't appear anywhere in your data you'll need to use proc tabulate or a different proc with the the preloadfmt option.

ballardw
Super User

I would recommend using 1) custom formats and 2) Proc Tabulate, Means or Report with the Preloadfmt option

proc format library=work;
value yndr
1='Yes'
2='No'
7="Don't Know"
9="Refused";
run;
data junk;
   do i = 1 to 5; x=1;output;end;
   do i = 1 to 3; x=2;output;end;
   do i = 1 to 4; x=7;output;end;
run;

proc tabulate data=junk;
   class x / preloadfmt missing;
   format x yndr.;
   table x, n='Count'
         /printmiss misstext='0';
run;

The misstext to show the zero for a missing count, otherwise it will display your current default for missing values.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 507 views
  • 0 likes
  • 3 in conversation