BookmarkSubscribeRSS Feed
dawidkaz
Calcite | Level 5

I need to build the model with 8 explanatory variables using stepwise selection:

 

ods graphics on;
proc phreg data=w1 alpha=0.05 namelen=32;
class &zm_class. app_number_of_children_f;
model ttd * rc(0,1) = act_age-numeric-act_CAll_All &zm_class. app_number_of_children_f / ties = breslow rl=wald selection=stepwise slentry=0.001
                           slstay=0.0001   ;
ods graphics off;

stop=8 is not working, Is there other way to that rather tha minimising slentry and slstay or picking the variables selected at the 8th step ?

 

Thank you 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

What does "step 8 is not working" mean? What didn't work? Why do you think it didn't work? Is there an error? If so, what error?

 

Also, what is the value of macro variable &ZM_CLASS?

--
Paige Miller
FreelanceReinh
Jade | Level 19

Hello @dawidkaz,

 

I think the stepwise effect selection method is not compatible with pre-specifying the number of explanatory variables in the model. So, you may want to try SELECTION=FORWARD and SELECTION=BACKWARD, each in conjunction with STOP=8. If there really is an outstanding subset of exactly 8 predictors (not sure how you know this number beforehand), chances are that the two selection processes end up with the same model.

 

Alternatively, you could narrow down the set of potential model variables to, say, 10-12 predictors (e.g., using stepwise selection) and then write a macro to construct all possible models (without interactions) involving exactly 8 predictors from this superset (e.g., comb(12,8)=495). The macro could create a dataset containing relevant statistics of your choice taken from (ODS) output datasets for each model. A review and analysis of this dataset together with subject matter considerations (plausibility, etc.) could finally support the decision for a "best" 8-variable model.

 

Edit: @PaigeMiller: The documentation says: "The STOP= option has no effect when SELECTION=NONE or STEPWISE." And perhaps I should have mentioned the general concerns against automatic variable selection that you have (rightly) expressed in various posts.

PaigeMiller
Diamond | Level 26

@FreelanceReinh wrote:

Hello @dawidkaz,

 

I think the stepwise effect selection method is not compatible with pre-specifying the number of explanatory variables in the model. So, you may want to try SELECTION=FORWARD and SELECTION=BACKWARD, each in conjunction with STOP=8. If there really is an outstanding subset of exactly 8 predictors (not sure how you know this number beforehand), chances are that the two selection processes end up with the same model.

 

Alternatively, you could narrow down the set of potential model variables to, say, 10-12 predictors (e.g., using stepwise selection) and then write a macro to construct all possible models (without interactions) involving exactly 8 predictors from this superset (e.g., comb(12,8)=495). The macro could create a dataset containing relevant statistics of your choice taken from (ODS) output datasets for each model. A review and analysis of this dataset together with subject matter considerations (plausibility, etc.) could finally support the decision for a "best" 8-variable model.

 

Edit: @PaigeMiller: The documentation says: "The STOP= option has no effect when SELECTION=NONE or STEPWISE." And perhaps I should have mentioned the general concerns against automatic variable selection that you have (rightly) expressed in various posts.


All excellent points. I hate stepwise, I think it is something I would never use and never recommend (and so I really didn't know any more, although I Might have known at one time) that STOP= doesn't work in this situation.

 

I advise all posters not to say "it doesn't work" or "there was an error" and then provide no additional information about what doesn't work or what the error was. Additional information is always needed, those very brief descriptions of the problem "it doesn't work" or "there was an error" are never sufficient, and follow up questions are always needed unless someone like you @FreelanceReinh is willing to do some digging.

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 899 views
  • 0 likes
  • 3 in conversation