BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ronein
Onyx | Level 15

Hello

In the following example I want to show also categories with frequency=0

In this example there is nobody with category "Left" so I want to show 0 under this category.

What is the way to do it please using proc tabulate?

 

Data rawtbl;
input ID status ;
cards;
1 2
2 2
3 1
4 3
5 3 
6 2
7 2
8 1
9 3
10 1
;
run;

proc format ;
value oorderCode
1='worse'
2='Better'
3='Same'
4='Left'
;
Run;

title;
PROC TABULATE DATA=rawtbl f=comma21.;
	VAR ID   ;
	CLASS status /	ORDER=UNFORMATTED MISSING;
	TABLE status="" all='TOTAL',
	     ID=''*N='No_Customers'
		 ID=''*pctn='PCT_No_Customers'*f=my1pct. /box="Status";
    format status oorderCode.;
RUN;
1 ACCEPTED SOLUTION
3 REPLIES 3
Ronein
Onyx | Level 15

I know how to do it in proc report

proc report data=rawtbl nowd completerows;
column ID status PCTN;
define status /group format=oorderCode. preloadfmt exclusive;
define ID /N format=4. 'Freq';
define PCTN / 'PCTN' format=percent9.1;
run;
Ronein
Onyx | Level 15

Great.

As I see the answer is to use PRELOADFMT  option  with Printmiss

title;
PROC TABULATE DATA=rawtbl f=comma21.;
	VAR ID   ;
	CLASS status / MISSING PRELOADFMT;
	TABLE status="" all='TOTAL',
	     ID=''*N='No_Customers'
		 ID=''*pctn='PCT_No_Customers'*f=my1pct. /box="Status" Printmiss MissText='';
    format status oorderCode. ;
RUN;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Update

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1909 views
  • 1 like
  • 2 in conversation