Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- how to output proc logistic parameters (ORs, CI) i...

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-08-2010 02:05 PM

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;

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;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

10-08-2010 02:29 PM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Paige

10-08-2010 02:44 PM

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;

%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;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

10-08-2010 03:06 PM

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.

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Paige

10-08-2010 03:16 PM

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....

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

10-08-2010 03:32 PM

> 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?

> 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

> 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?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Paige

10-08-2010 04:06 PM

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?

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?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

10-08-2010 04:14 PM

> 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.

> 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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

10-11-2010 12:38 PM

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;

%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;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

10-12-2010 09:57 AM

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

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

10-12-2010 10:19 AM

> 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.

> 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.