BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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;
10 REPLIES 10
Paige
Quartz | Level 8
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.
deleted_user
Not applicable
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;
Paige
Quartz | Level 8
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.
deleted_user
Not applicable
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....
Paige
Quartz | Level 8
> 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?
deleted_user
Not applicable
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?
Paige
Quartz | Level 8
> 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.
deleted_user
Not applicable
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;
SPR
Quartz | Level 8 SPR
Quartz | Level 8
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
Paige
Quartz | Level 8
> 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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 2314 views
  • 0 likes
  • 3 in conversation