- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Dear SAS Masters,
I have a data (just a sample) like the following (real data have more variables). I want to calculate Odds Ratios (OR) and 95% CI using logistic regression models adjusting several other factors . Because I need to do it for more 100 variables, that means I will have to build more 100 + logistic models and then pick the OR and 95% from the results and then put in my report.
Does any master here have good solution that can put the outputs of many logistic models together in one or fewer tables? I can write Macro to deal with repeated logistic regression, but I am scratching my head for having to put these results all together. Only OR and 95%CI, whether they are together or separate, with or without other outputs, doesn't matter, as long as they can be aggregated in one table, that could save me tons of work. Thanks in advance if you could offer some programming tips.
Joy
Adjusted variables (co-variance): Adjust1 Adjust2
Var1-Var4 compared between Group using logistic regression
Group=1 as reference group, Group 2, Group 3 are all compared to Group 1, so the odds ratios are for 1 vs 2, 1 vs 3, etc
ID Adjust1 Adjust2 Var1 Var2 Var3 Var4 Group
01 1 23 1 2 2 1 3
02 2 40 2 1 2 2 1
03 1 20 2 2 2 1 2
04 2 35 1 1 2 2 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Dear SAS Masters,
I have a data (just a sample) like the following (real data have more variables). I want to calculate Odds Ratios (OR) and 95% CI using logistic regression models adjusting several other factors . Because I need to do it for more 100 variables, that means I will have to build more 100 + logistic models and then pick the OR and 95% from the results and then put in my report.
Does any master here have good solution that can put the outputs of many logistic models together in one or fewer tables? I can write Macro to deal with repeated logistic regression, but I am scratching my head for having to put these results all together. Only OR and 95%CI, whether they are together or separate, with or without other outputs, doesn't matter, as long as they can be aggregated in one table, that could save me tons of work. Thanks in advance if you could offer some programming tips.
(Sorry if you see this as repeated question, I am just trying to find a solution for an urgent report. )
Joy
Adjusted variables (co-variance): Adjust1 Adjust2
Var1-Var4 compared between Group using logistic regression
Group=1 as reference group, Group 2, Group 3 are all compared to Group 1, so the odds ratios are for 1 vs 2, 1 vs 3, etc
ID Adjust1 Adjust2 Var1 Var2 Var3 Var4 Group
01 1 23 1 2 2 1 3
02 2 40 2 1 2 2 1
03 1 20 2 2 2 1 2
04 2 35 1 1 2 2 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When you say "more than 100 variables," do you mean that there are 100 responses and the explanatory effects for each model are the same? For example, do the models look something like
Y1 = X1-X4;
Y2 = X1-X4;
...
Y100 = X1-X4;
If so, look transposing the data to long form and using BY-group analysis. The odds ratios and CIs will automatically appear in the same output table. For details, see "An easy way to run thousands of regressions in SAS."
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Dear SAS Masters,
I have a data (just a sample) like the following (real data have more variables). I want to calculate Odds Ratios (OR) and 95% CI using logistic regression models adjusting several other factors . Because I need to do it for more 100 variables, that means I will have to build more 100 + logistic models and then pick the OR and 95% from the results and then put in my report.
Does any master here have good solution that can put the outputs of many logistic models together in one or fewer tables? I can write Macro to deal with repeated logistic regression, but I am scratching my head for having to put these results all together. Only OR and 95%CI, whether they are together or separate, with or without other outputs, doesn't matter, as long as they can be aggregated in one table, that could save me tons of work. Thanks in advance if you could offer some programming tips.
Joy
Adjusted variables (co-variance): Adjust1 Adjust2
Var1-Var4 compared between Group using logistic regression
Group=1 as reference group, Group 2, Group 3 are all compared to Group 1, so the odds ratios are for 1 vs 2, 1 vs 3, etc
ID Adjust1 Adjust2 Var1 Var2 Var3 Var4 Group
01 1 23 1 2 2 1 3
02 2 40 2 1 2 2 1
03 1 20 2 2 2 1 2
04 2 35 1 1 2 2 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Search on lexjansen.com for sample code. Though to be honest, I've found manipulating other peoples macros more difficult that writing my own from scratch. You may find a perfect example though...
Because I need to do it for more 100 variables, that means I will have to build more 100 + logistic models and then pick the OR and 95% from the results and then put in my report.
Another option is to reformat your data somehow so you can use BY group processing, this isn't always possible.
If you need further help, I suggest you post sample data as a data step and what you want as output. Anything you have so far is helpful as well.
@Xiaoyi wrote:
Dear SAS Masters,
I have a data (just a sample) like the following (real data have more variables). I want to calculate Odds Ratios (OR) and 95% CI using logistic regression models adjusting several other factors . Because I need to do it for more 100 variables, that means I will have to build more 100 + logistic models and then pick the OR and 95% from the results and then put in my report.
Does any master here have good solution that can put the outputs of many logistic models together in one or fewer tables? I can write Macro to deal with repeated logistic regression, but I am scratching my head for having to put these results all together. Only OR and 95%CI, whether they are together or separate, with or without other outputs, doesn't matter, as long as they can be aggregated in one table, that could save me tons of work. Thanks in advance if you could offer some programming tips.
Joy
Adjusted variables (co-variance): Adjust1 Adjust2
Var1-Var4 compared between Group using logistic regression
Group=1 as reference group, Group 2, Group 3 are all compared to Group 1, so the odds ratios are for 1 vs 2, 1 vs 3, etc
ID Adjust1 Adjust2 Var1 Var2 Var3 Var4 Group
01 1 23 1 2 2 1 3
02 2 40 2 1 2 2 1
03 1 20 2 2 2 1 2
04 2 35 1 1 2 2 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You don't need a macro. Simply use the PERSIST option in an ODS OUTPUT statement to accumulate tables across multiple procedure runs. For example, these statements save two tables across both procedure runs in the two named data sets:
ods output FitStatistics(persist)=fs ModelInfo(persist)=mf;
proc logistic data=ingots;
model r/n=heat;
run;
proc logistic data=ingots;
model r/n=soak;
run;
ods output close;
Find the name of the table you want to keep in the "Details: ODS Table Names" section of the PROC LOGISTIC documentation. You might also want to use the ODDSRATIO statement in PROC LOGISTIC to generate the odds ratios. Again, see the PROC LOGISTIC documentation.
Also see this note for how to easily fit a series of models in separate procedure runs using a different predictor in each model.
However, note that if you run a bunch of separate models, the odds ratios you obtain for a particular predictor are only adjusted for the other predictors in the individual model. Any predictors that you want *adjusted* odds ratios for must have all of the predictors you want to adjust for in the model.