BookmarkSubscribeRSS Feed
dineshhnk
Calcite | Level 5

hi 

I have a dataset like vital as below.

there are total 3 trt possible values 1,0,2

My report should has below format, how can I do it ?

As proc frequency will give me only 2(40 %)  and 3(60 % ),  and not 0% for Trt3  and total n and %

 

Characteristic                          Trt0                         Trt1               Trt3          Total

Number of Subjects                 2 (40%)              3 (60%)           0 (0%)       5  (100 %)


data vital;
input subjid trt age GENDER race $ sysp diasp pulse ;
datalines ;
1 1 20 1 Asia 120 60 80
2 0 25 1 America 108 70 .
3 1 35 1 Asia 110 87 68
4 1 20 0 Indian 120 60 85
5 0 42 0 Middle 104 85 63
;
run;

1 REPLY 1
ed_sas_member
Meteorite | Level 14

Hi @dineshhnk 

 

You can use a format to define all the modalities (even if not observed) and then use the 'preloadfmt' and 'printmiss' options in proc tabulate:

 

data vital;
	input subjid trt age GENDER race $ sysp diasp pulse;
	datalines;
1 1 20 1 Asia 120 60 80
2 0 25 1 America 108 70 .
3 1 35 1 Asia 110 87 68
4 1 20 0 Indian 120 60 85
5 0 42 0 Middle 104 85 63
;
run;

proc format;
	value trtfmt 0='Trt0' 1='Trt1' 2='Trt2';
run;

option missing=0;

proc tabulate data=vital;
	class trt / preloadfmt;
	table (trt='Characteristic' all) * (n='Number of Subjects' pctn='%') / printmiss;
	format trt trtfmt.;
run;

All the best,

 

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 750 views
  • 0 likes
  • 2 in conversation