Date: Fri, 7 Jul 2006 08:44:52 +0100
ReplyTo: Ian Wakeling <ian.wakeling@HANANI.QISTATS.CO.UK>
Sender: "SAS(r) Discussion" <SASL@LISTSERV.UGA.EDU>
From: Ian Wakeling <ian.wakeling@HANANI.QISTATS.CO.UK>
Subject: Re: error control in iml
ContentType: text/plain; charset="iso88591"
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 nonsingular" 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: <SASL@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=xxwt*xx;
>
> BETA=INV(xbar`*xbar)*xbar`*ybar;
>
> SIGMA=SQRT((ybarxbar*BETA)`*(ybarxbar*BETA)/(NR));
>
> SE=SIGMA*SQRT(VECDIAG(INV(xbar`*xbar)));
>
> TVALUE=BETA/SE;
>
> pvalue=(*1*PROBT(ABS(TVALUE),NR))**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
>
