Help using Base SAS procedures

how to output proc logistic parameters (ORs, CI) into a data set?

Reply
N/A
Posts: 0

how to output proc logistic parameters (ORs, CI) into a data set?

I am running a macro that produces about 600 odds ratios...i want to ouput just the parameters (odds ratios and Confidence intervals) into a dataset....I imagine there would be several data sets, so then I would have to use proc append correct? How would I go about doing this?

my code below:


%macro proclogistic;

%do i=1 %to 11;
%do j=1 %to 64;


proc logistic data=f.merged12;
class race_group healthdistrict &&var&j (ref=&&ref&j);
strata caseid;
model &&outcome&i(event='1')= race_group healthdistrict &&var&j;

run;

%end;
%end;



%mend proclogistic;

%proclogistic;
Super Contributor
Posts: 281

Re: how to output proc logistic parameters (ORs, CI) into a data set?

The ODS OUTPUT statement will allow you to put any desired statistic into a SAS data set. Yes, you will need PROC APPEND as well.
N/A
Posts: 0

Re: how to output proc logistic parameters (ORs, CI) into a data set?

I tried a simple ods output statement but the dataset only prints out like 16 observations and 10 variables...

%macro proclogistic;

%do i=7 %to 7;
%do j=1 %to 64;
ods output ParameterEstimates=Parameter_Estimates23;

proc logistic data=f.merged12 out=analysis2;
class race_group healthdistrict &&var&j (ref=&&ref&j);
strata caseid;
model &&outcome&i(event='1')= race_group healthdistrict &&var&j;

run;
ods output close;
%end;
%end;



%mend proclogistic;

%proclogistic;
Super Contributor
Posts: 281

Re: how to output proc logistic parameters (ORs, CI) into a data set?

Looking at your code more carefully ...

I can't say I have ever tried (or even thought of) doing a logistic regression with 66 independent variables, but I have to believe that part of the problem is right there. It might have given you only 10 variables because you can't estimate more variables. How many observations in the dataset?

To take this one step further, I don't think a logistic regression with 66 independent variables is a good idea, period. These variables are most likely correlated with one another and this makes it impossible to interpret the model.

This is something you will need to dig into more carefully, as I don't have your data.
N/A
Posts: 0

Re: how to output proc logistic parameters (ORs, CI) into a data set?

running this macro is the same as running each logsitic regression model separately....it is adjusted for only two specific variables....there is no multiple comparisons problem. I am doing study looking at 64 different risk factor variables for pediatric cancers...variable are not correlated with each other (there is no collinearity)....anyways, I will keep searching for why the output dataset only consists of the two adjustement variabels and the last variable in the macro....
Super Contributor
Posts: 281

Re: how to output proc logistic parameters (ORs, CI) into a data set?

> variable are not correlated with
> each other (there is no collinearity)

Hard to imagine a real data set with 66 variables doesn't have collinearity. Yes, I see what you mean about how there are only three variables in a model at a time (I misunderstood your macro at first), but if you ever want to compare models, this collinearity will be present between the 64 different risk factor variables (even when only one is in each model) and make the comparison difficult or meaningless.

> I tried a simple ods output statement but the dataset only
> prints out like 16 observations and 10 variables...

So what is the problem? What is missing? What were you expecting?
N/A
Posts: 0

Re: how to output proc logistic parameters (ORs, CI) into a data set?

basically, the dataset prints out the parameters for the 2 adjustment variables "health district" and "race_group" and then the results for the last variable with my macro....so the only paramters printed to the dataset are from 3 variables.....my macro has 64....how do I get it to print to the dataset the other 63 variable parameters?

About the collinearity....how else would u suggest I do this? It is quite tedious to run odds ratios individually using proc logistic for each variable (64) on 11 different outcomes....I've already done this comparing different models with different adjustement variables....we have narrowed it down to what we want to adjust on so I thought this would make the work less tedious...ideas?
Super Contributor
Posts: 281

Re: how to output proc logistic parameters (ORs, CI) into a data set?

> basically, the dataset prints out the parameters for
> the 2 adjustment variables "health district" and
> "race_group" and then the results for the last
> variable with my macro....so the only paramters
> printed to the dataset are from 3 variables.....my
> macro has 64....how do I get it to print to the
> dataset the other 63 variable parameters?

Your macro needs a PROC APPEND after each run of PROC LOGISTIC.

> About the collinearity....how else would u suggest I
> do this? It is quite tedious to run odds ratios
> individually using proc logistic for each variable
> (64) on 11 different outcomes....I've already done
> this comparing different models with different
> adjustement variables....we have narrowed it down to
> what we want to adjust on so I thought this would
> make the work less tedious...ideas?

My usual reply when someone has 64 independent (and most likely correlated) variables is to use Partial Least Squares (PLS) regression, or a variation of it. There are logistic versions of PLS, although I don't know if you can get a logistic version of PLS out of SAS's PROC PLS (I never really tried).

The basic idea is that PLS works better in the presence of correlation between the independent variables than other techniques which don't account for the correlation. But you also have to change your mindset ... PLS provides combinations of variables that are predictive, rather than a single (or small number of) variables that you might want to get from ordinary regression and logistic regression methods.
N/A
Posts: 0

Re: how to output proc logistic parameters (ORs, CI) into a data set?

I can't seem to figure it out....here is my program...how would I incorporate Proc append in this program?


%macro proclogistic;

%do i=7 %to 7;
%do j=1 %to 64;

ods output OddsRatios = Test;
proc logistic data=f.merged12;

class race_group healthdistrict &&var&j (ref=&&ref&j);
strata caseid;
model &&outcome&i(event='1')= race_group healthdistrict &&var&j;

run;

%end;
%end;

%mend proclogistic;



%proclogistic;
Super Contributor
Super Contributor
Posts: 365

Re: how to output proc logistic parameters (ORs, CI) into a data set?

Hello SASer,

I usually use the following %IF %THEN %ELSE structure to perform appending:

%macro proclogistic;

%do i=7 %to 7;
%do j=1 %to 64;

ods output OddsRatios = Test;
proc logistic data=f.merged12;

class race_group healthdistrict &&var&j (ref=&&ref&j);
strata caseid;
model &&outcome&i(event='1')= race_group healthdistrict &&var&j;
run;
/* Adding index variables to identify output */;
data test;
retain i j;
set test;
i=&i;
j=&j;
run;
/* Combining Outputs */;
%if i=&7 and &j=1 %then %do; data testf; set test; run; %end;
%else %do; data testf; set testf test; run; %end;

%end;
%end;

SPR
Super Contributor
Posts: 281

Re: how to output proc logistic parameters (ORs, CI) into a data set?

> I can't seem to figure it out....here is my
> program...how would I incorporate Proc append in this
> program?

As I said the first time I mentioned PROC APPEND, it goes right after PROC LOGISTIC.
Ask a Question
Discussion stats
  • 10 replies
  • 616 views
  • 0 likes
  • 3 in conversation