Hello,
I want to sum two columns by treatment and add a new row called "total" for each treatment into each of the columns that I want summed. I am using SAS 9.4. Here is an example of what I have and what I am trying to do:
I was able to add the rows pretty easily using the insert function in SQL:
proc sql; insert into COHORT values (1,"Total", ., ., .) values (2,"Total", ., ., .) values (3,"Total", ., ., .); quit;
TRT_ARM
Country
Efficacy_endpt
Total_event
1
Peru
300
17
1
Spain
48
0
1
Awesomvania
25
8
2
Peru
325
51
2
Spain
46
9
2
Awesomvania
98
5
3
Peru
73
21
3
Spain
45
1
3
Awesomvania
375
30
1
Total
.
.
2
Total
.
.
3
Total
.
.
But I am having some difficulty filling the rows. I want them to look like this:
TRT_ARM
Country
Efficacy_endpt
Total_event
1
Peru
300
17
1
Spain
48
0
1
Awesomvania
25
8
2
Peru
325
51
2
Spain
46
9
2
Awesomvania
98
5
3
Peru
73
21
3
Spain
45
1
3
Awesomvania
375
30
1
Total
373
25
2
Total
469
65
3
Total
493
52
I have tried using the count function in SQL, but that gives me a column for each treatment arm with the sum I want, but it is in its own column.
I also welcome any SUGI papers that you think might help! Thank you!
Donald S.
... View more