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

I have attached the sample code that I am using along with a sample dataset and an excel file of what I am trying to achieve. 

 

I have a data set with variable that are not mutually exclusive but I want to layer them into a table as percentages of the over all count. 

                       TREATMENT

                               A                           B                             C

Total People  =  10   100%               8    100%               13  100%

White            =  3       30%               5     62,5%               3     23%

Fast               =  7      70%               0        0%                 12   92%

Ugly               =  5      50%               5     62.5%               7     54%

 

I can not get this to work right. Help me Obi Wan, you are my only hope. 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Your example data has no value of UGLY or Fast and your code does not show any variable labeled as such so your example table is moderately useless.

I am not going to open Excel files of unknown origin.

You would probably do yourself a favor by having your VAR variables have a value other than 1, such as 0 for the "doesn't have the condition".

 

I suspect that you want PCTSUM in some form possibly:

proc tabulate data=work.death_table 
         format=7.0 style=[font=("Arial",9pt) ] missing ;
	class partial_blind ;

	var trt_x_dth 
		trt_x_wdr 
		trt_x_pn 
		trt_x_pc
		trt_x_oth
		total;
	table total (trt_x_dth trt_x_wdr 
          trt_x_pn trt_x_pc trt_x_oth)/*(N COLPCTN*F=pctfmt.)*/  , 

				(partial_blind)*(N PCTsum<total>*F=pctfmt.) 
            ( all="Total")*(N PCTsum<total>*F=pctfmt.)
  ;
	label
      trt_x_dth="Deaths" 
      trt_x_wdr="Withdrawl" 
      trt_x_pn="PN" 
      trt_x_pc="PC" 
      trt_x_oth="OTH"
      partial_blind='Treatment Group'
   ;
run;

I moved the labels for the variables out of the table statement so it would be easier to read.

The the Pctsum<total> uses the sum of the variable Total for a denominator in the percentage calculation. DO not use any of the Rowpctsum, Colpctsum, Pagepctsum or the similar Pctn functions this way or you may create a serious fault that will crash SAS.

 

View solution in original post

1 REPLY 1
ballardw
Super User

Your example data has no value of UGLY or Fast and your code does not show any variable labeled as such so your example table is moderately useless.

I am not going to open Excel files of unknown origin.

You would probably do yourself a favor by having your VAR variables have a value other than 1, such as 0 for the "doesn't have the condition".

 

I suspect that you want PCTSUM in some form possibly:

proc tabulate data=work.death_table 
         format=7.0 style=[font=("Arial",9pt) ] missing ;
	class partial_blind ;

	var trt_x_dth 
		trt_x_wdr 
		trt_x_pn 
		trt_x_pc
		trt_x_oth
		total;
	table total (trt_x_dth trt_x_wdr 
          trt_x_pn trt_x_pc trt_x_oth)/*(N COLPCTN*F=pctfmt.)*/  , 

				(partial_blind)*(N PCTsum<total>*F=pctfmt.) 
            ( all="Total")*(N PCTsum<total>*F=pctfmt.)
  ;
	label
      trt_x_dth="Deaths" 
      trt_x_wdr="Withdrawl" 
      trt_x_pn="PN" 
      trt_x_pc="PC" 
      trt_x_oth="OTH"
      partial_blind='Treatment Group'
   ;
run;

I moved the labels for the variables out of the table statement so it would be easier to read.

The the Pctsum<total> uses the sum of the variable Total for a denominator in the percentage calculation. DO not use any of the Rowpctsum, Colpctsum, Pagepctsum or the similar Pctn functions this way or you may create a serious fault that will crash SAS.

 

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!

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
  • 503 views
  • 0 likes
  • 2 in conversation