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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 336 views
  • 0 likes
  • 2 in conversation