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 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 7 Jul 2006 08:44:52 +0100
Reply-To:     Ian Wakeling <ian.wakeling@HANANI.QISTATS.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Wakeling <ian.wakeling@HANANI.QISTATS.CO.UK>
Subject:      Re: error control in iml
Content-Type: text/plain; charset="iso-8859-1"

Qi,

Why not test to see if the matrix is singular before trying to calculate the inverse? If I read your code correctly it is actually quite simple since xbar is a column vector and xbar`*xbar is a scalar, so you will only get the "matrix has to be non-singular" message when xbar`*xbar=0. There's the det() function if its more complicated than this.

Ian.

----- Original Message ----- From: "qi zhang" <shellyzhang77@GMAIL.COM> To: <SAS-L@LISTSERV.UGA.EDU> Sent: Thursday, July 06, 2006 11:19 PM Subject: error control in iml

> Dear SAS user, > > I have a question I tried really hard but couldn't figure it out.I want to > calculate p value for 100 independent variables using the same > code.10independent variable is exacted from matrix XXX. I have the > following SAS > iml code: > > start genp(k) global (xxx,wt,ybar,N,R); /****begin of module*****/ > > xx=xxx[,k]; > > xbar=xx-wt*xx; > > BETA=INV(xbar`*xbar)*xbar`*ybar; > > SIGMA=SQRT((ybar-xbar*BETA)`*(ybar-xbar*BETA)/(N-R)); > > SE=SIGMA*SQRT(VECDIAG(INV(xbar`*xbar))); > > TVALUE=BETA/SE; > > pvalue=(*1*-PROBT(ABS(TVALUE),N-R))**2*; > > return(pvalue); /****end of module*******/ > > finish genp; > > p=genp({*1*,*2*,*3*,*4*,*5*,*6*,*7*,*8*,*9*,*10,...,100*}); > > print p; > > > The problem is that for some variable, the matrix of xbar*xbar is singular > so that it will generate error message and stops.How can I just ignore those > error and set pvalue to missing for singular matrix . > I looked up SAS manual and tried to use call push commend and add the > following code into the module, it still doesn't work. > > errcode = {" if errors >= 0 then do;", > "call push(errcode);pvalue=.; resume; end;", > } ; > call push (errcode); > errors = 0; > > I really appreciate if somebody can give me a hint. > Thanks in advance. > Qi > > > > -- > Division of Epidemiology and Biostatistics > Department of Enivermental Health > University of Cincinnati >


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