In medical journals, binary outcomes (such as *mortality,* *length of stay > 30 days*, or *acute kidney injury [AKI]*) are typically published in a Table as the number of events over the number of patients or subjects in the group, i.e. *n/N*.

### For example:

In this Table from a large clinical trial, 462 out of 3443 patients taking aspirin developed acute kidney injury (AKI) after a surgical procedure, versus 426 out of 3462 patients who were taking placebo.

### From here, it is easy to calculate a risk ratio…

The risk ratio is simply the:

(risk in the treatment group) / (risk in the control group)

Here, this is:

(462/3443) / (426/3462) = **1.09**

This is seen in the Table:

### Ok, so how do I do this calculation in Stata?

In Stata, if you want to compute a risk ratio and P value, Stata’s -csi- command can be used. **However, to use -csi- it is first necessary to calculate, within each group, the difference between the total number of subjects and the number of events. **This is because the -csi- command expects the data to be entered as individual cell counts rather than “events” and “total subjects”. You also need to enter the *number of events* for each group first, followed by the *remainder* of each group. This is really counterintuitive, but it stems from the way Stata thinks — it wants you to populate the four cells of a 2-by-2 contingency table.

Below is an example of how Stata would expect the above AKI outcome to be input. You can see the *risk ratio* (same thing as the *relative risk*) is, as expected, 1.09. In order to enter this command, I had to flip back and forth on my computer twice between the source Table and the calculator app on my Mac to calculate the difference between the total group size and the number of events, for both groups. This takes a few seconds, is prone to making errors, *and takes minutes* if you need to perform the calculations several times for different outcomes. **What a waste of time!**

### There is a better way!

The command I wrote, -csti-, allows you to enter the *n/N* naturally and avoids having to compute the difference between the total subjects and number of events. This saves substantial time, especially when computing many relative risks, or verifying many P values, such as would be done by Journal Editors.

At the Canadian Journal of Anesthesia, where I am an Associate Editor, I often verify P values for various hypothesis tests, on a random basis, to ensure they were done correctly. When I find errors, warning bells go off in my head! At the very least, the authors need to explain why the values in their manuscript were wrong. Because of the frequency with which I verify these values, I need a fast, efficient, way of doing these calculations.

So, I wrote a wrapper for -csi-, called –**csti**-. With this program, the same output as above can be easily obtained directly from the numbers in the Table, and *in a more sensible order*. That is, you enter the number of events over the total number of patients per group directly, followed by the same data for the other group.

Of course, to really understand it is best to see an example! But first you must install -csti-. This is trivial to do.

### How to install -csti-

As with any Stata command, installation of a user-written command proceeds with the command -ssc install-, as below:

Once this is done, you have only to enter the numbers of events/number per group, naturally, as follows (from the AKI example above):

**And then you are done!**

I hope you will find -csti- useful. Please contact me if you have any questions, and feel free to leave comments below!