BookmarkSubscribeRSS Feed
KPatra
Calcite | Level 5

I am getting the following error message, any help is appreciated:

ERROR: (execution) Character argument should be numeric.

operation : QUAD at line 6707 column 5

operands  : *LIT1021, INTERVAL

*LIT1021      1 row       1 col     (character, size 6)

TLAINT

INTERVAL      1 row       2 cols    (character, size 2)

H  K1

statement : CALL at line 6707 column 5

traceback : module KBETAFIND at line 6707 column 5

Below is the code:

PROC IML;

  START TLAINT(U) GLOBAL(N1,NMAX,Z1,C,ZBETA);

/*THIS MODULE CREATES THE INTEGRAND TO BE SOLVED;*/

Z1 = J(1,1,.);

  TEMP = Z1[1,1]*SQRT((N1+NMAX)/N1)-C;

  ZB = TEMP><ZBETA;

  AA1 = C*(C+ZB)-U**2;

  AA2 = SQRT((C+ZB)**2-U**2);

  ARG = AA1/AA2;

  YY1 = CDF("NORMAL",ARG);

  YY = YY1*PDF("NORMAL",U);

  RETURN(YY);

  FINISH TLAINT;

START KBETAFIND(A) GLOBAL(N1,NMAX,C,ZBETA,H,ALPHA,Z1);

/*THIS MODULE SOLVES K AND ZBETA GIVEN N1,NMAX, C AND ZBETA;*/

ALPHA = 0.025;

C = J(1,1,.);

KMAX = J(1,1,.);

K = A[1];

ZBETA = A[2];

KMAX = C+ZBETA;

K1 = MIN(K,KMAX);

  INTERVAL = {H K1};

  CALL QUAD(INT,"TLAINT", INTERVAL);

  FUTILE = 1 - CDF("NORMAL",H);

  FF = INT - (FUTILE - ALPHA);

  RETURN (FF);

FINISH KBETAFIND;

START PWRCAL(Z1) GLOBAL(C,ZBBTA,N1,NMAX,N2,DELTA,S);

/*THIS MODULE CREATES THE INTEGRAND TO CALCULATE UNCONDITIONAL POWER;*/

/*WILL NEED TO BE CALLED IN WITHIN DO LOOP*/

  ZBBTA=ZZ_;

  S = SQRT(2/N1);

  N2 = ((((C+ZBBTA)**2)/(Z1**2) -1)*N1)><NMAX;

  CPARG = (C*SQRT(N1+N2) - Z1*SQRT(N1) - N2*DELTA/SQRT(2))/SQRT(N2);

  PWRARG = (1-CDF("NORMAL",CPARG))*PDF("NORMAL",Z1-DELTA/S);

  RETURN PWRARG;

FINISH PWRCAL;

HH = T(DO(.7,1.2,(1.2-.7)/49));

NMAX_=J(NROW(HH),1,.);

UNP  =J(NROW(HH),1,.);

CPOWER  =J(NROW(HH),1,.);

NTMAX = 192;

  DO I = 1 TO NROW(HH);

  H = HH[I,1];

  FUTILE = 1 - CDF("NORMAL",H);

  N1 = 40;

  NMAX = NTMAX - N1;

  NMAX_ = NMAX;

  DO WHILE (UNP<0.8);

  N1 = N1+1;

  S = SQRT(2/N1);

  NMAX= NTMAX - N1;

  NMAX_ = NMAX;

  OPTN = {2,4}`;

  CALL NLPTR(RC,XR,"KBETAFIND",{2, 0.8}`,OPTN) ;

  KVAL = XR[1]; ZBBTA = XR[2];

  CALL QUAD(INT,"PWRCAL",HH[I,1]||KVAL);

  UNP = CDF("NORMAL",DELTA/S - KVAL) + INT;

   END;

  NS1 = N1;

  START EXPN(Z1) GLOBAL(NS1,C,ZBBTA,NMAX,DELTA);

  S = SQRT(2/NS1);

  EN_ = ((((C+ZBBTA)**2)/(Z1**2) -1)*NS1)><NMAX;

  F = EN_*PDF("NORMAL",Z1-DELTA/S);

  FINISH EXPN;

  CALL QUAD(ENINT,"EXPN",HH[I,1]||KVAL);

  EN = NS1 + ENINT;

  CPOWER = CDF("NORMAL",ZBBTA);

  PRINT "ITERATION" I;

  END;

  CREATE FINAL VAR{HH,KVAL,CPOWER,NS1,EN,NMAX_};

  APPEND;

  CLOSE FINAL;

QUIT;

4 REPLIES 4
IanWakeling
Barite | Level 11

The cause of the error is that you are specifying a character matrix for the interval for integration, you are passing the names of the matrices instead of the values.  You need to use a 2 value numeric vector with the left and right hand limits.  So replace INTERVAL = {H K1}; with INTERVAL = H || K1;

I think there are other errors in your code.  For example the loop "DO I = 1 TO NROW(HH);" has no matching END statement.

KPatra
Calcite | Level 5

I tried H || K1 before and it didn't work. The DO loop you mentioned did have an END as you can see from the code. Sure there are errors but I don't find it so far.

IanWakeling
Barite | Level 11

I stand by H || K1, and think there are other problems with your code.   Test out the function TLAINT before you start calling it from QUAD, and check the value of 'C'.   Also move the module called EXPN, you can not have it inside a loop.

KPatra
Calcite | Level 5

Thanks, your suggestions were very helpful and I made several modifications for the code to work.

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!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 4 replies
  • 2691 views
  • 3 likes
  • 2 in conversation