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

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
Meteorite | Level 14

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
Meteorite | Level 14

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;

 

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
  • 3 replies
  • 1425 views
  • 1 like
  • 2 in conversation