cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
lily1287
Level I

Automate odds ratio to populate a table

Hi all! Is there an easy way to automate a table like the following for a large data set? Essentially I'm reporting my data in the following way with number and percentage in each group and the odds ratio with the confidence interval:

 

 Total n (%)Survived n (%)Died n (%)OR (CI)
Femalex (x%)x (x%)x (x%)x.xx (x.xx-x.xx)
Heart diseasex (x%)x (x%)x (x%)x.xx (x.xx-x.xx)

 

I've been doing my analysis using fit x by y, adding in the odds ratio, and looking at the contingency table and odds ratio then manually typing it into word. I know I should be able to use the tabulate function to streamline the process via excel to get the middle three columns but am interested to know if someone has a good way to list the OR in a table. Even if it's something like this it would be helpful, especially if you can make it into a script to run for all the variables I want stats on:

 

 ORlower 95%Upper 95%
Femalex.xxx.xxx.xx
Heart diseasex.xxx.xxx.xx

 

Any tips or tricks? I'm not great at using the JSL code but am working on learning!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Automate odds ratio to populate a table

There's a way to extract information from reports in JMP using a combination of using the GUI to investigate the report structure and scripting to pull specific information.

 

Step 1 is to do your analysis, then right click on the header closest to the information you want (red space below), then select Edit...Show Tree Structure.

Jed_Campbell_1-1671812127490.png

 

 

Jed_Campbell_0-1671812098059.png

In the window that pops up, find the info you're looking for, then the name of the header just above it in the hierarchy. In this case,  NumberColBox(8) has the Odds Ratio, so you'll need to remember NumberColBox(8) for the scripting step.

Jed_Campbell_2-1671812366040.png

Step 2 is to write the script. The first few lines in the script below are just for opening a file that this will work on; the magic starts at the "Export the report layer" comment. Basically, you're creating a separate object that has a copy of all the hierarchy of the report in it, then querying that separate object to get the text/number you need. In the script below, I send the odds ratio to the clipboard, since you mentioned needing to paste it. You could also use scripting to do other things with the value.

 

Names Default To Here( 1 );
//open the data file and run analysis, including odds ratio
dt = Open( "$SAMPLE_DATA/Lung Cancer.jmp" );
obj = dt << Contingency( Y( :Lung Cancer ), X( :Smoker ), Freq( :Count ), Odds Ratio( 1 ) );

//export the report layer, so it can be queried
r = obj << report;

//from looking through the "Show Tree Structure" manually to find the number needed
oddsratio = r[NumberColBox(8)] << Get; //pulls a list of what in that NumberColBox
show(oddsratio[1]); //shows the first item in the list (the odds ratio)
Set Clipboard (round(oddsratio[1],3)); //copies rounded odds ratio to the clipboard for easy pasting

Here's a link to a great resource for learning more about scripting the report layer.

 

View solution in original post

2 REPLIES 2

Re: Automate odds ratio to populate a table

There's a way to extract information from reports in JMP using a combination of using the GUI to investigate the report structure and scripting to pull specific information.

 

Step 1 is to do your analysis, then right click on the header closest to the information you want (red space below), then select Edit...Show Tree Structure.

Jed_Campbell_1-1671812127490.png

 

 

Jed_Campbell_0-1671812098059.png

In the window that pops up, find the info you're looking for, then the name of the header just above it in the hierarchy. In this case,  NumberColBox(8) has the Odds Ratio, so you'll need to remember NumberColBox(8) for the scripting step.

Jed_Campbell_2-1671812366040.png

Step 2 is to write the script. The first few lines in the script below are just for opening a file that this will work on; the magic starts at the "Export the report layer" comment. Basically, you're creating a separate object that has a copy of all the hierarchy of the report in it, then querying that separate object to get the text/number you need. In the script below, I send the odds ratio to the clipboard, since you mentioned needing to paste it. You could also use scripting to do other things with the value.

 

Names Default To Here( 1 );
//open the data file and run analysis, including odds ratio
dt = Open( "$SAMPLE_DATA/Lung Cancer.jmp" );
obj = dt << Contingency( Y( :Lung Cancer ), X( :Smoker ), Freq( :Count ), Odds Ratio( 1 ) );

//export the report layer, so it can be queried
r = obj << report;

//from looking through the "Show Tree Structure" manually to find the number needed
oddsratio = r[NumberColBox(8)] << Get; //pulls a list of what in that NumberColBox
show(oddsratio[1]); //shows the first item in the list (the odds ratio)
Set Clipboard (round(oddsratio[1],3)); //copies rounded odds ratio to the clipboard for easy pasting

Here's a link to a great resource for learning more about scripting the report layer.

 

lily1287
Level I

Re: Automate odds ratio to populate a table

Thanks so much!!