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

Hello All, 

 

I may have to resort to proc report but if I can help it I would like to this in Proc Tabulate if I could. 

 

Below is an example of the table I want and get with proc report. What makes this table difficult in proc tabulate is the three different denominators used to create this table. 

All Randomized, Subjects with at least 1 AE and then the breakdown of the AE's them selves. I am able to create this table in proc tabulate but I have to include the missing option which provided rows with a missing (.) value that would rather not have. I want to Suppress any row that Proc Tabulate produces that is not seen below. 

 

I have attached a sample dataset and a piece of code. The first proc tabulate procedure is the only one that is in question here. The other two will be built based on if I can solve the first. 

 

 

 

 

Treatment Group

 

Selected or Anticipated Adverse Events and Safety Outcomes

Expected Event Rate

A

B

C

Total1
N (%)

All Randomized as of 22Mar2021

 

44.0

62.0

61.0

167 (100.0)

# of subjects with at least 1 event

 

25 (63.0

35 (64.0

37 (71.0

97 (58.1)

Pneumonia

40-60%

3 (8.0)

6 (11.0)

7 (13.0)

16 (9.6)

Other infections (including UTI and bacteremia)

17-40%

 

2 (4.0)

5 (10.0)

7 (4.2)

Malignant cardiac arrhythmia

46-65%

2 (5.0)

5 (9.0)

5 (10.0)

12 (7.2)

Seizures

20-40%

3 (8.0)

1 (2.0)

 

4 (2.4)

Neurological worsening

30-50%

18 (45.0

24 (44.0

19 (37.0

61 (36.5)

Electrolyte abnormalities

70-80%

2 (5.0)

4 (7.0)

7 (13.0)

13 (7.8)

Venous thrombotic disease

10-20%

 

1 (2.0)

1 (2.0)

2 (1.2)

Coagulopathies

10-20%

1 (3.0)

 

3 (6.0)

4 (2.4)

1 ACCEPTED SOLUTION

Accepted Solutions
PhilC
Rhodochrosite | Level 12

Does it have to be PROC TABULATE?  I've solved a similar requirement using PROC PRINT where I placed numbers, parentheses and carriage returns into strings (all output destination dependent) printing it to my ODS destination.  

View solution in original post

5 REPLIES 5
PhilC
Rhodochrosite | Level 12

Does it have to be PROC TABULATE?  I've solved a similar requirement using PROC PRINT where I placed numbers, parentheses and carriage returns into strings (all output destination dependent) printing it to my ODS destination.  

GreyJoy
Obsidian | Level 7
Ultimately I had to go with Proc Report. There is no way to cherry pick cells in Proc tabulate.
ballardw
Super User

@GreyJoy wrote:

Hello All, 

 

I may have to resort to proc report but if I can help it I would like to this in Proc Tabulate if I could. 

 

Below is an example of the table I want and get with proc report. What makes this table difficult in proc tabulate is the three different denominators used to create this table. 

All Randomized, Subjects with at least 1 AE and then the breakdown of the AE's them selves. I am able to create this table in proc tabulate but I have to include the missing option which provided rows with a missing (.) value that would rather not have. I want to Suppress any row that Proc Tabulate produces that is not seen below. 

 

I have attached a sample dataset and a piece of code. The first proc tabulate procedure is the only one that is in question here. The other two will be built based on if I can solve the first. 

 

You do not describe what any of the "denominators" might be, or for which varible.

The tabulate code in your attachment does not show any place you are attempting percentages only sums.

libname sas xlsx "INSERT _ PATH\suppress rows in tabulate date.xlsx";
proc sort data=sas.sheet1 out=ae_dataset_sorted1 nodupkey;
	by zSubjectID f104q12;
run;
proc format;
	value names
		1="Pneumonia"
		2="Other infections (including UTI and bacteremia)"
		3="Malignant cardiac arrhythmia"
		4="Seizures"
		5="Neurological worsening"
		6="Electrolyte abnormalities"
		7="Venous thrombotic disease"
		8="Coagulopathies"
		98="NA"
		.1="All Randomized as of &reportdt2" 
		.5="# of Subjects with at least 1 Events"
		;
run;

/* Over view of Observed vs Expected Coutcomes */
proc tabulate data=work.ae_dataset_sorted1 missing out=table;
/*	where f104q12 in(1:8);*/
	class f104q12 F102zTreatmentID rando a_ae ;
	var count ;
	table rando a_ae f104q12,F102zTreatmentID*count all="total" / ;
	format f104q12 names.;
run;


/**************************************************************************************/
/*********		Attempt at bypassing the problem. This is Last Resort	**************/
/**************************************************************************************/
/*				data table_2;*/
/*					set work.table;*/
/*					if rando =1 then f104q12=.1;*/
/*					if a_ae=1 then f104q12=.5;*/
/*					if _type_ in(0110) and rando ne . then output;*/
/*					if _type_ in(0101) and a_ae ne . then output;*/
/*					if _type_ in(1100) and f104q12 not in(. 98) then output;*/
/*				run;*/
/**/
/*					proc tabulate data=work.table_2;*/
/*						class f104q12 F102zTreatmentID;*/
/*						var count_sum;*/
/*						table f104q12="",F102zTreatmentID*count_sum sum="total";*/
/*					run;*/
/**************************************************************************************/
proc sort data=work.AE_dataset out=ae_dataset_sorted2 nodupkey;
	by zSubjectID SOCname PTname;
run;
/* ALL ADVERSE EVENTS */
proc tabulate data=work.ae_dataset_sorted2 ;
	class SOCname PTname F102zTreatmentID;
	var count;
	table SOCname*PTname,F102zTreatmentID*count all="total" / ;
run;
/* ALL SERIOUS ADVERSE EVENTS */
proc tabulate data=work.ae_dataset_sorted2;
	where serious_sae=1;
	class SOCname PTname F102zTreatmentID;
	var count;
	table SOCname*PTname,F102zTreatmentID*count all="total";
run;


Without an input data set hard to tell.

 

I do multiple things by making the data work for me an a few simple bits. One thing is if you have a variable that is coded 1/0 (numeric) for yes/no then an N statistic tells you how many records have the value set, Sum tells you how many records have the 1 value (yes) set, and the mean will give you a decimal percent.

 

So in a data set you can create a number variables and use those. Example you should be able to run as the SASHELP.Class data set should be included in your install.

data example;
   set sashelp.class;
   overweight = (weight > 100);
   reallyoverweight = (weight>120);
run;

proc tabulate data=example;
   class sex age;
   var overweight reallyoverweight;
   tables all='All children' sex age sex*age,
          (overweight reallyoverweight)*(n='# measurements'
                    sum='Number'*f=f5. mean='%'*f=percent8.1)
   ;
   label overweight='Weight > 100'
         reallyoverweight='Weight > 120'
   ;
run;

IF you had shown an attempt to calculate percentages we might be able to help a bit more. Tabulate for the PCTN or PCTSUM statistic will allow you to provide another variable to use as denominator.

Not great but demonstrates a syntax example.

proc tabulate data=example ;
   class sex age;
   table sex,
         age*( n pctn<sex>);
run;
GreyJoy
Obsidian | Level 7

I do have an input dataset. I provided it right next to the code. 

ballardw
Super User

@GreyJoy wrote:

I do have an input dataset. I provided it right next to the code. 


Many users here don't want to download Excel files because of virus potential, organization policy may prohibit downloading such and others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 1037 views
  • 0 likes
  • 3 in conversation