楼主: herbertshu
3501 1

proc iml过程中出现ERROR: (execution) Invalid argument to function. [推广有奖]

  • 0关注
  • 0粉丝

学前班

80%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
30 点
帖子
1
精华
0
在线时间
4 小时
注册时间
2011-10-12
最后登录
2017-2-15

楼主
herbertshu 发表于 2014-2-20 15:32:57 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
急求解答。谢谢!
程序为(错误部分标红)
proc IML;
   use all;
   read all var {_Ni_} into allN;
   read all var {variance} into variance;  
   close all;  

/** read in all RRs and save as matrix R **/
   use noRef;
   read all var {rr} into R;
   read all var {_Ni_} into N;
   read all var {_Ai_} into initialA;
   read all var {study} into study;
   read all var{dose} into dose;
   read all var {type} into stype;  
   close noRef;
/** read in the sums of subjects for reference level **/
   use refN;
   read all var {_Ni_} into N0;
   close refN;

/** read in the sums of cases and subjects for each study **/
   use mout;
   read all var {sumA p studyNum} into T;
   close mout;


/** define function f for cohort study **/     
   start f(A) global (N01, M, N1, R1);
   A = t(A);
   temp=(N01/(M-A[+])) # (A/N1)-R1; *risk ratio?;
   return (temp);
   finish;

/** define function g for case control study **/     
   start g(A) global (N01, M, N1, R1);
   A = t(A);
   temp=(N01/(M-A[+])-1) # (A/(N1-A))-R1;
   return (temp);
   finish;

   sump=0;
   sump2=0;  

   part1=0;
   part2=0;   

do s=1 to nrow(T); *loop for each study;
   N01=N0;  *total number of subjects in reference group;
   M=T[s,1];   *total number of cases in all groups;
   p=T[s,2];   

   study_s=T[s,3];

   *actual name;
   stu=study[sump+1];

   N1=N[(sump+1):(sump+p),]; * # of subjects in each group;
   R1=R[(sump+1):(sump+p),]; * rr in each group;
   startA=initialA[(sump+1):(sump+p),]; * initial values=actual values;

   allN1=allN[(sump2+1):(sump2+p+1),];  * total N for all groups;
   variance1=variance[(sump2+1):(sump2+p+1),];
   dose1=dose[(sump+1):(sump+p),];   * include spline variables;

   type=stype[sump+1,1];
  optn=p;

   C=J(p,p,0);
   cor=J(p,p,1);

/** 1. cohort with person time **/
   if type=1 then do;
    call nlplm(rc, root, "f", startA, optn);
    A0=M-t(root)[+]; *estimated cell # for reference group;  
    ahat=t(A0||root); *estimated cell #s for all groups;

  * print ahat A0 N01 allN1;

    rrhat=(ahat/allN1)/(A0/N01);   

    s2=1/ahat+1/A0;

   do i=1 to p;
     do j=1 to p;
       if i=j then do;
        C[i,j]=variance1[i+1]; end;
         else do;
           cor[i,j]=(1/A0)/sqrt((1/root+1/A0)*(1/root[j]+1/A0));                    
           C[i,j]= cor[i,j]*sqrt(variance1[i+1]*variance1[j+1]);
           end;     
        end;
       end;
end;


/** 2. cohort study  with total observation instead of person time **/
   else if type=2 then do;
   call nlplm(rc, root, "f", startA, optn);
   A0=M-t(root)[+]; *estimated cell # for reference group;  
   ahat=t(A0||root); *estimated cell #s for all groups;  
   rrhat=(ahat/allN1)/(A0/N01);      

   s2=1/ahat-1/allN1 + 1/A0 -1/N01;
   se=sqrt(s2);   
   do i=1 to p;
    do j=1 to p;
    if i=j then C[i,j]=variance1[i+1];
    else do;
       cor[i,j]=(1/A0-1/N01)/(se[i+1]*se[j+1]);  
       C[i,j]=cor[i,j]*(sqrt(variance1[i+1]*variance1[j+1]));
       end;     
       end;
      end;
      end;

  /** 3. case-control study **/
   else if type=3 then do;      
   call nlplm(rc, root, "g", startA, optn);
   A0=M-t(root)[+]; *estimated cell # for reference group;  
   ahat=t(A0||root); *estimated cell #s for all groups;  
   riskhat0=A0/(N01-A0);
   riskhat=ahat/(allN1-ahat);
   rrhat=riskhat/riskhat0;

   s2=1/A0+1/(N01-A0)+1/ahat+1/(allN1-ahat);
   se=sqrt(s2);

   do i=1 to p;
    do j=1 to p;
    if i=j then C[i,j]=variance1[i+1];
    else do;
       cor[i,j]=(1/A0+1/(N01-A0))/(se[i+1]*se[j+1]);  
       C[i,j]=cor[i,j]*(sqrt(variance1[i+1]*variance1[j+1]));
       end;     
       end;
      end;

      end;

   k=1;
   lowerC=J(p*(p+1)/2, 1,.);
   do i=1 to p;
     do j=1 to i;
        lowerC[k]=C[i,j];
        k=k+1;
     end;
   end;

   vbstar=inv(t(dose1)*inv(C)*dose1);
   sestar=sqrt(vbstar);
   bstar=vbstar*t(dose1)*inv(C)*log(R1);
   GreenlandRR=exp(1*bstar);
   GreenlandUB=exp(1*(bstar+1.96*sqrt(vbstar)));
   GreenlandLB=exp(1*(bstar-1.96*sqrt(vbstar)));

   tmp=tmp//(ahat||rrhat||s2);

   tmp2=tmp2//(study_s||bstar|| sestar||GreenlandRR|| GreenlandLB|| GreenlandUB);

    lowerVar=lowerVar//(J(p*(p+1)/2,1,study_s)||lowerC);
   sumP=sump+p;  
   sump2=sump2+p+1;
/** go back to the next study **/


end; /** end of do s=1 to nrow(T) */
NOTE: ABSGCONV convergence criterion satisfied.
NOTE: ABSGCONV convergence criterion satisfied.
NOTE: ABSGCONV convergence criterion satisfied.
ERROR: (execution) Invalid argument to function.


operation : SQRT at line 3306 column 15
operands  : vbstar


vbstar      1 row       1 col     (numeric)


-3.621E-7


statement : ASSIGN at line 3306 column 4



create g_ahat from tmp [colname={Greenland_Est_A  rrhat greenVar}];
   append from tmp;

   create Greenland from tmp2 [colname={studyNum g_bstar g_sestar g_RRstar g_LBstar g_UBstar}];
   append from tmp2;

   create lowerVar from lowerVar[colname={study var}];
   append from lowerVar;

   free /;
quit;
run;

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:EXECUTION function argument invalid Valid execution function ERROR

沙发
bakoll 发表于 2015-1-23 23:26:01
函数调用出错,看一下你在程序中出错的是哪个式子,然后看一下是否这个式子中调用的变量出现类似分母为零的这种情况调用

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 18:11