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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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