LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 15 Jul 2004 15:52:54 -0700
Reply-To:     Dale McLerran <stringplayer_2@YAHOO.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dale McLerran <stringplayer_2@YAHOO.COM>
Subject:      Re: best subset logistic regression
Comments: To: "Dunn, Toby" <tdunn@tea.state.tx.us>
In-Reply-To:  <748343794E05734F9D9E9BBF2CA6D2140DBA0C@LYNDON.tea.state.tx.us>
Content-Type: text/plain; charset=us-ascii

Toby,

The problem is with the code which Eva Ivits had sent. She had coded the %let statement. I must say that I didn't really pay attention to what the %let statement was doing. I simply moved it out of the PROC SQL. There is no reason to have a %let statement embedded in a procedure or a data step. I didn't look to see what operation the %let statement was performing. You are right that this %let statement is not needed at all.

As for the case of string values in the dictionary tables, it has always been my understanding that they are stored as upper case. However, as I stated in my post, I don't like to leave such assumptions to chance. Who knows when such an assumption will no longer hold? Therefore, as I told Eva, I prefer to enforce the correct case comparison. Therefore, I posted that Eva should compare upcase(libname) with upcase('lstgreyl') and upcase(memname) with upcase("best_subsets"). Yes, that is not as efficient as assuming that the dictionary tables store strings in upper case and writing the comparison strings in upper case. However, being the lazy person that I am and not wanting to check whether the characters at either end of 'lstgreyl' were 1's or l's (which can be hard to distinguish with some fonts!) and not wanting to check that I typed the strings correctly, I left the strings as Eva had coded them and simply upcased everything. To be honest, I don't think there will be much performance loss between my code and yours. I prefer my code as it does not leave anything to an assumption and is safer with regard to transcription errors. YMMV

Dale

--- "Dunn, Toby" <tdunn@tea.state.tx.us> wrote: > Dale you have one major problem and some clean up that's needs to be > done: > > %macro vica ; > proc sql noprint ; > select (nobs -delobs) into: num > from dictionary.tables > where libname="LSTGREY1" > and memname="BEST_SUBSETS" ; > quit ; > > %do i=1 %to &num ; > > data _null_ ; > set lstgreyl.best_subsets ; > if _N_ = &i ; > call symput ('list', VariablesInModel) ; > run ; > > proc logistic data=lstgrey.lstgreyl ; > model OUTCOME = &list ; > run ; > > %end ; > %mend ; > %vica ; > > > You don't need to create another &num variable use the one you create > in > the SQL. And when hitting the dictionary or sashelp meta data > libnames > and memnames are always stored in uppercase. > > HTH > Toby Dunn > > -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > Dale McLerran > Sent: Thursday, July 15, 2004 4:48 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: best subset logistic regression > > Eva, > > You might try replacing > > proc sql noprint ; > select (nobs -delobs) into: num > from dictionary.tables > where libname='lstgreyl' > and memname="best_subsets" ; > %let num = &num; > quit ; > > > with > > > proc sql noprint ; > select (nobs -delobs) into: num > from dictionary.tables > where upcase(libname)=upcase('lstgreyl') > and upcase(memname)=upcase("best_subsets") ; > quit ; > %let num = &num; > > > I believe that the libname and memname values are stored as > upper case, so you may not need to write upcase(libname) and > upcase(memname). However, when comparing string values, it is > always best, in my book, to make certain that you are comparing > upper case values to upper case values. The way to ensure that > is to upcase on both sides of a test for equality of two strings. > > HTH, > > Dale > > --- Eva Ivits <Eva.Ivits@FELIS.UNI-FREIBURG.DE> wrote: > > Dear All, > > > > best subset logistic regression with the options best=3 and > > selection=score merly reports the best predictor variables being in > > the > > 3 best models but no model parameters, goodness of fit statistics, > > etc. > > When I want to check the models with the different subsets of > > predictors > > I will have to run them manually one by one. This problem is solved > > by a > > macro I've found on the Internet in the articel of Shtatland, > > Kleinman > > and Cain under: > > http://www2.sas.com/proceedings/sugi28/258-28.pdf > > > > So I thought I would apply this macro to my best subset regression > > output which I got with the "ods" option. But it does not run. Is > > there > > somebody who could maybe advise me what the problem is? > > > > Here is what I did: > > > > proc logistic data=lstgreyl.ranks ; > > model b (event="1")=focdivmr ndvimr nirmr pcamr varmr > > /best=3 > > selection=score; > > ods output BestSubsets=lstgreyl.best_subsets ; /*with this I got > > the > > table of the best models reporting only the variables*/ > > run ; > > > > options mprint symbolgen mlogic ; > > > > %macro vica ; /*here starts the macro I've found on the Internet*/ > > proc sql noprint ; > > select (nobs -delobs) into: num > > from dictionary.tables > > where libname='lstgreyl' > > and memname="best_subsets" ; > > %let num = &num; > > quit ; > > > > %do i=1 %to &num ; > > > > data _null_ ; > > set lstgreyl.best_subsets ; > > if _N_ = &i ; > > call symput ('list', VariablesInModel) ; > > run ; > > > > proc logistic data=lstgrey.lstgreyl ; > > model OUTCOME = &list ; > > run ; > > > > %end ; > > %mend ; > > %vica ; > > > > and then this error message comes: > > > > MLOGIC(VICA): Beginning execution. > > MPRINT(VICA): proc sql noprint ; > > MPRINT(VICA): select (nobs -delobs) into: num from > > dictionary.tables > > where libname='lstgreyl' > > and memname="best_subsets" ; > > NOTE: No rows were selected. > > MLOGIC(VICA): %LET (variable name is NUM) > > WARNING: Apparent symbolic reference NUM not resolved. > > ERROR: The text expression &NUM contains a recursive reference to > the > > macro variable NUM. The > > macro variable will be assigned the null value. > > MPRINT(VICA): quit ; > > NOTE: The SAS System stopped processing this step because of > errors. > > NOTE: PROCEDURE SQL used: > > real time 0.01 seconds > > cpu time 0.00 seconds > > > > SYMBOLGEN: Macro variable NUM resolves to > > ERROR: %EVAL function has no expression to evaluate, or %IF > statement > > has no condition. > > ERROR: The %TO value of the %DO I loop is invalid. > > ERROR: The macro VICA will stop executing. > > MLOGIC(VICA): Ending execution. > > --- > > > > Something is wrong with the num variable that no rows were > selected. > > As > > I am no programmer guru I have no idea what the problem actually > is. > > I > > would be so grateful if somebody could help. > > > > Warm regards, > > Eva > > > > -- > > Dr. Eva Ivits-Wasser > > Abt. Fernerkundung und LIS > > (Dep. of Remote Sensing and LIS) > > Tennenbacherstr. 4. > > D-79106 Freiburg > > Deutschland > > > > tel: +49 761 2033699 > > fax: +49 761 2033701 > > > > eva.ivits@felis.uni-freiburg.de > > > > > ===== > --------------------------------------- > Dale McLerran > Fred Hutchinson Cancer Research Center > mailto: dmclerra@fhcrc.org > Ph: (206) 667-2926 > Fax: (206) 667-5977 > --------------------------------------- > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail is new and improved - Check it out! > http://promotions.yahoo.com/new_mail >

===== --------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@fhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

__________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail


Back to: Top of message | Previous page | Main SAS-L page