全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3445 3
2009-08-02
程序没有报错,当是不能运行出结果,有提示“NOTE: Module MAIN is undefined in IML; cannot be RUN.”而我在之前的用run来跑程序时事没有问题的,现在非常confused,不知道如何解决好?大家有什么好想法在此分享,小弟不胜感激。在网上查了原因是"If a RUN statement is submitted without specifying the name of the module that you wish to execute, the RUN statement attempts to run the module named MAIN. If you have defined a module without a name, or with a name of MAIN, then RUN; is a valid statement that will run the module whose name defaulted to MAIN. "
2429  proc iml;
NOTE: IML Ready
2430
2431  use Stag3data2;
2432  read all into data;
NOTE: I/O required temporary file to be opened.
2433  /*show names; */
2434  /*print data;*/
2435  start maxFunc(F) global(data);
2436  sum=0;
2437  Uf=J(1,3,0);
2438  Um=J(1,3,0);
2439  Ud=J(1,3,0);
2440  Pf=J(1,3,0);
2441  Pm=J(1,3,0);
2442  Pd=J(1,3,0);
2443  Vh=J(1,2,0);
2444  G=J(1,3,0);
2445  /*do i=1 to 1988;*/
2446  do i=1 to 994;
2447  prob=0;
2448  do j=1 to 4;
2449
2450  /*stag1*/
2451
2452  /*Pf1 stands for fπ1*/
2453
2454  z=(i-1)*4+j;
2455
2456  /* change to z */
2457
2458  Uf[1]=F[1]*data[z,5]+F[2]*data[z,6]+F[3]*data[z,7]+F[4]*data[z,8]
2459  +F[5]*data[z,9]+F[6]*data[z,10]+F[7]*data[z,11]+F[8]*data[z,12]+F[9]*data[z,13]+F[10]*data[z,14];
2460
2461  Uf[2]=F[11]*data[z,15]+F[12]*data[z,16]+F[13]*data[z,17]+F[14]*data[z,18]
2462  +F[15]*data[z,19]+F[16]*data[z,20]+F[17]*data[z,21]+F[18]*data[z,22]+F[19]*data[z,23]+F[20]*data[z,24];
2463
2464  Uf[3]=F[21];
2465
2466  Pf[1]=exp(Uf[1])/(exp(Uf[1])+exp(Uf[2])+exp(Uf[3]));
2466!                                                     /* Pf[1] stand for fπ1 */
2467  Pf[2]=exp(Uf[2])/(exp(Uf[1])+exp(Uf[2])+exp(Uf[3]));
2468  Pf[3]=exp(Uf[3])/(exp(Uf[1])+exp(Uf[2])+exp(Uf[3]));
2469
2470  /*Pm1 stand for mπ1*/
2471
2472  Um[1]=F[22]*data[z,5]+F[23]*data[z,6]+F[24]*data[z,7]+F[25]*data[z,8]
2473  +F[26]*data[z,9]+F[27]*data[z,10]+F[28]*data[z,11]+F[29]*data[z,12]+F[30]*data[z,13]+F[31]*data[z,14];
2474
2475  Um[2]=F[32]*data[z,15]+F[33]*data[z,16]+F[34]*data[z,17]+F[35]*data[z,18]
2476  +F[36]*data[z,19]+F[37]*data[z,20]+F[38]*data[z,21]+F[39]*data[z,22]+F[40]*data[z,23]+F[41]*data[z,24];
2477
2478  Um[3]=F[42];
2479  Pm[1]=exp(Um[1])/(exp(Um[1])+exp(Um[2])+exp(Um[3]));
2480  Pm[2]=exp(Um[2])/(exp(Um[1])+exp(Um[2])+exp(Um[3]));
2481  Pm[3]=exp(Um[3])/(exp(Um[1])+exp(Um[2])+exp(Um[3]));
2482
2483  /*Pd1 stand for dπ1*/
2484
2485  Ud[1]=F[43]*data[z,5]+F[44]*data[z,6]+F[45]*data[z,7]+F[46]*data[z,8]
2486  +F[47]*data[z,9]+F[48]*data[z,10]+F[49]*data[z,11]+F[50]*data[z,12]+F[51]*data[z,13]+F[52]*data[z,14];
2487
2488  Ud[2]=F[53]*data[z,15]+F[54]*data[z,16]+F[55]*data[z,17]+F[56]*data[z,18]
2489  +F[57]*data[z,19]+F[58]*data[z,20]+F[59]*data[z,21]+F[60]*data[z,22]+F[61]*data[z,23]+F[62]*data[z,24];
2490
2491  Ud[3]=F[63];
2492  Pd[1]=exp(Ud[1])/(exp(Ud[1])+exp(Ud[2])+exp(Ud[3]));
2493  Pd[2]=exp(Ud[2])/(exp(Ud[1])+exp(Ud[2])+exp(Ud[3]));
2494  Pd[3]=exp(Ud[3])/(exp(Ud[1])+exp(Ud[2])+exp(Ud[3]));
2495
2496  /*stag2*/
2497
2498  Vf=
2499  Vh[1]=F[64]*data[z,28]+F[65]*data[z,31]+F[66]*data[z,34];
2499!                                                           /*Vh stand for house vote */
2500  Vh[2]=F[64]*data[z,29]+F[65]*data[z,32]+F[66]*data[z,35];
2501
2502  G[1]=(1-Pf[3]*Pm[3]*Pd[3])*(exp(Vh[1])/(exp(Vh[1])+exp(Vh[2])));
2502!                                                                  /*G stand for probability of household*/
2503  G[2]=(1-Pf[3]*Pm[3]*Pd[3])*(exp(Vh[2])/(exp(Vh[1])+exp(Vh[2])));
2504  G[3]=Pf[3]*Pm[3]*Pd[3];
2505
2506  /*stag3*/
2507
2508  Prof=Pf[1]*data[z,28]+Pf[2]*data[z,29]+Pf[3]*data[z,30];
2508!                                                          /*Pf means to choose the available fπ1,2,3*/
2509  Prom=Pm[1]*data[z,31]+Pm[2]*data[z,32]+Pm[3]*data[z,33];
2510  Prod=Pd[1]*data[z,34]+Pd[2]*data[z,35]+Pd[3]*data[z,36];
2511
2512  G[3]=G[1]*data[z,25]+G[2]*data[z,26];
2512!                                                          /* G[3] stand for group choice*/
2513  fP11=1;
2514  fP21=exp(Uf[1])/(exp(Uf[1])+exp(Uf[3]));
2514!                                                        /*fP21 :probability of switch from channel 2 to 1*/
2515  fP23=exp(Uf[3])/(exp(Uf[1])+exp(Uf[3]));
2516  fP12=exp(Uf[2])/(exp(Uf[2])+exp(Uf[3]));
2517  fP22=1;
2518  fP13=exp(Uf[3])/(exp(Uf[2])+exp(Uf[3]));
2519
2520  mP11=1;
2521  mP21=exp(Um[1])/(exp(Um[1])+exp(Um[3]));
2522  mP23=exp(Um[3])/(exp(Um[1])+exp(Um[3]));
2523  mP12=exp(Um[2])/(exp(Um[2])+exp(Um[3]));
2524  mP22=1;
2525  mP13=exp(Um[3])/(exp(Um[2])+exp(Um[3]));
2526
2527  dP11=1;
2528  dP21=exp(Ud[1])/(exp(Ud[1])+exp(Ud[3]));
2529  dP23=exp(Ud[3])/(exp(Ud[1])+exp(Ud[3]));
2530  dP12=exp(Ud[2])/(exp(Ud[2])+exp(Ud[3]));
2531  dP22=1;
2532  dP13=exp(Ud[3])/(exp(Ud[2])+exp(Ud[3]));
2533
2534  fP=fP11*data[z,41]+fP21*data[z,42]+fP23*data[z,43]+fP12*data[z,44]+fP22*data[z,45]+fP13*data[z,46];
2535  mP=mP11*data[z,47]+mP21*data[z,48]+mP23*data[z,49]+mP12*data[z,50]+mP22*data[z,51]+mP13*data[z,52];
2536  dP=dP11*data[z,53]+dP21*data[z,54]+dP23*data[z,55]+dP12*data[z,56]+dP22*data[z,57]+dP13*data[z,58];
2537
2538  prob=prob + Prof*Prom*Prod*G[3]*fP*mP*dP;
2539  end;
2540  sum=sum*prob ;
2541  end;
2542  return(sum);
2543  finish maxFunc;
NOTE: Module MAXFUNC defined.
2544
2545  optn={1 2};
2546  X=J(1,66,0);
2547  X[1,1] = 0.7865;
2548  X[1,2] = -1.173888;
2549  X[1,3] = -0.901912;
2550  X[1,4] = 2.52522;
2551  X[1,5] = 1.934948;
2552  X[1,6] = 5.106454;
2553  X[1,7] = -2.823555;
2554  X[1,8] = 3.528326;
2555  X[1,9] = -2.357012;
2556  X[1,10] = -0.525734;
2557  X[1,11] = -12.653302;
2558  X[1,12] = -3.099612;
2559  X[1,13] = 4.539191;
2560  X[1,14] = 2.001213;
2561  X[1,15] = 0.153087;
2562  X[1,16] = 2.228049;
2563  X[1,17] = -1.640786;
2564  X[1,18] = -0.220159;
2565  X[1,19] = -1.042585;
2566  X[1,20] = 5.483434;
2567  X[1,21] = -1.852272 ;
2568  X[1,64]=3;
2569  X[1,65]=7;
2570  X[1,66]=10;
2571  call nlpcg(rc,xres,"maxFunc",X,optn);
NOTE: ABSGCONV convergence criterion satisfied.
2572  run;
NOTE: Module MAIN is undefined in IML; cannot be RUN.
2573  quit;
NOTE: Exiting IML.
NOTE: 30078 workspace compresses.
NOTE: “PROCEDURE IML”所用时间(总处理时间):
      实际时间         3:02.79
      CPU 时间         3:02.34
二维码

扫码加我 拉你入群

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

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

全部回复
2009-8-2 22:46:47
去掉run后,程序依然没有结果输出,难道是程序设计的错误吗?我检查过了,程序没有逻辑上的错误。实在搞不明白,怎么办好呢?
日志如下:
4311 call nlpcg(rc,xres,"maxFunc",X,optn);
NOTE: ABSGCONV convergence criterion satisfied.
4312 /*run;*/
4313 quit;
NOTE: Exiting IML.
NOTE: 30078 workspace compresses.
NOTE: “PROCEDURE IML”所用时间(总处理时间):
实际时间 2:58.21
CPU 时间 2:58.06
二维码

扫码加我 拉你入群

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

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

2011-8-9 00:45:24
What does "Note: xx workspace compresses" mean?
    SAS/IML has two logical areas of memory, symbolspace and workspace. Workspace itself is divided into sections called extents. Symbolspace contains symbol table information and compiled statements (modules), while workspace contains the matrix data values. Memory allocation for these areas is done automatically by IML, and it generally does a good job setting these amounts (you can see what they are set to by issuing a SHOW MEMORY statement). Sometimes, however, an application may have only a few matrices with a large number of rows and/or columns, or a lot of matrices with only a small number of rows and/or columns. If IML does not find enough space to store the data values for a matrix, it will compress the current extent. If enough space is not available in the current extent after the compression, IML will open a new extent.

Program efficiency is reduced the more often workspace compressions must occur. One way to decrease the number of compressions is to increase the size of a workspace extent using the WORKSIZE= option in the PROC IML statement. Note that it is not necessary to eliminate compressions completely. In fact, you should be careful not to set very large values in the WORKSIZE= option in order to eliminate the workspace compressions completely (large relative to the amount of memory available on your computer) as this may interfere with the accessibility of IML and DATA step functions. Unfortunately, there is no way to know what the best value might be without a little trial and error. Use the SHOW MEMORY command to find the current settings and then increase the value from there.

二维码

扫码加我 拉你入群

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

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

2011-8-9 18:20:57
你没有IML 模块,就这么简单,IML是不包含在 SAS/base 里的
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群