why invalid subscript or subscript out of range?I am waiting for

Discussion in 'SAS (Statistical Analysis Software)' started by Yingan Lee, Aug 2, 2009.

  1. Yingan Lee

    Yingan Lee Guest

    2153 proc iml;
    NOTE: IML Ready
    2154
    2155 use Stag3data2;
    2156 read all into data;
    NOTE: I/O required temporary file to be opened.
    2157 /*show names; */
    2158 /*print data;*/
    2159 start maxFunction(F) global(data);
    2160 sum=0;
    2161 Uf=J(1,3,0);
    2162 Um=J(1,3,0);
    2163 Ud=J(1,3,0);
    2164 Pf=J(1,3,0);
    2165 Pm=J(1,3,0);
    2166 Pd=J(1,3,0);
    2167 Vh=J(1,2,0);
    2168 G=J(1,3,0);
    2169 do i=1 to 1988;
    2170 prob=0;
    2171 do j=1 to 4;
    2172
    2173 /*stag1*/
    2174
    2175 /*Pf1 stands for fπ1*/
    2176
    2177 z=(i-1)*4+j;
    2178
    2179 /* change to z */
    2180
    2181 Uf[1]=F[1]*data[z,5]+F[2]*data[z,6]+F[3]*data[z,7]+F[4]*data[z,8]
    2182 +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];
    2183
    2184 Uf[2]=F[11]*data[z,15]+F[12]*data[z,16]+F[13]*data[z,17]+F[14]*data
    [z,18]
    2185 +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];
    2186
    2187 Uf[3]=F[21];
    2188
    2189 Pf[1]=exp(Uf[1])/(exp(Uf[1])+exp(Uf[2])+exp(Uf[3]));
    2189! /* Pf[1] stand
    for fπ1 */
    2190 Pf[2]=exp(Uf[2])/(exp(Uf[1])+exp(Uf[2])+exp(Uf[3]));
    2191 Pf[3]=exp(Uf[3])/(exp(Uf[1])+exp(Uf[2])+exp(Uf[3]));
    2192
    2193 /*Pm1 stand for mπ1*/
    2194
    2195 Um[1]=F[22]*data[z,5]+F[23]*data[z,6]+F[24]*data[z,7]+F[25]*data[z,8]
    2196 +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];
    2197
    2198 Um[2]=F[32]*data[z,15]+F[33]*data[z,16]+F[34]*data[z,17]+F[35]*data
    [z,18]
    2199 +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];
    2200
    2201 Um[3]=F[42];
    2202 Pm[1]=exp(Um[1])/(exp(Um[1])+exp(Um[2])+exp(Um[3]));
    2203 Pm[2]=exp(Um[2])/(exp(Um[1])+exp(Um[2])+exp(Um[3]));
    2204 Pm[3]=exp(Um[3])/(exp(Um[1])+exp(Um[2])+exp(Um[3]));
    2205
    2206 /*Pd1 stand for dπ1*/
    2207
    2208 Ud[1]=F[43]*data[z,5]+F[44]*data[z,6]+F[45]*data[z,7]+F[46]*data[z,8]
    2209 +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];
    2210
    2211 Ud[2]=F[53]*data[z,15]+F[54]*data[z,16]+F[55]*data[z,17]+F[56]*data
    [z,18]
    2212 +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];
    2213
    2214 Ud[3]=F[63];
    2215 Pd[1]=exp(Ud[1])/(exp(Ud[1])+exp(Ud[2])+exp(Ud[3]));
    2216 Pd[2]=exp(Ud[2])/(exp(Ud[1])+exp(Ud[2])+exp(Ud[3]));
    2217 Pd[3]=exp(Ud[3])/(exp(Ud[1])+exp(Ud[2])+exp(Ud[3]));
    2218
    2219 /*stag2*/
    2220
    2221 Vf=
    2222 Vh[1]=F[64]*data[z,28]+F[65]*data[z,31]+F[66]*data[z,34];
    2222! /*Vh stand
    for house vote */
    why invalid subscript or subscript out of range?I am waiting for your
    reply online. Thank you !
    2223 Vh[2]=F[64]*data[z,29]+F[65]*data[z,32]+F[66]*data[z,35];
    2224
    2225 G[1]=(1-Pf[3]*Pm[3]*Pd[3])*(exp(Vh[1])/(exp(Vh[1])+exp(Vh[2])));
    2225! /*G
    stand for probability of household*/
    2226 G[2]=(1-Pf[3]*Pm[3]*Pd[3])*(exp(Vh[2])/(exp(Vh[1])+exp(Vh[2])));
    2227 G[3]=Pf[3]*Pm[3]*Pd[3];
    2228
    2229 /*stag3*/
    2230
    2231 Prof=Pf[1]*data[z,28]+Pf[2]*data[z,29]+Pf[3]*data[z,30];
    2231! /*Pf means
    to choose the available fπ1,2,3*/
    2232 Prom=Pm[1]*data[z,31]+Pm[2]*data[z,32]+Pm[3]*data[z,33];
    2233 Prod=Pd[1]*data[z,34]+Pd[2]*data[z,35]+Pd[3]*data[z,36];
    2234
    2235 G[3]=G[1]*data[z,25]+G[2]*data[z,26];
    2235! /* G[3]
    stand for group choice*/
    2236 fP11=1;
    2237 fP21=exp(Uf[1])/(exp(Uf[1])+exp(Uf[3]));
    2237! /*fP21 :probab
    ility of switch from channel 2 to 1*/
    2238 fP23=exp(Uf[3])/(exp(Uf[1])+exp(Uf[3]));
    2239 fP12=exp(Uf[2])/(exp(Uf[2])+exp(Uf[3]));
    2240 fP22=1;
    2241 fP13=exp(Uf[3])/(exp(Uf[2])+exp(Uf[3]));
    2242
    2243 mP11=1;
    2244 mP21=exp(Um[1])/(exp(Um[1])+exp(Um[3]));
    2245 mP23=exp(Um[3])/(exp(Um[1])+exp(Um[3]));
    2246 mP12=exp(Um[2])/(exp(Um[2])+exp(Um[3]));
    2247 mP22=1;
    2248 mP13=exp(Um[3])/(exp(Um[2])+exp(Um[3]));
    2249
    2250 dP11=1;
    2251 dP21=exp(Ud[1])/(exp(Ud[1])+exp(Ud[3]));
    2252 dP23=exp(Ud[3])/(exp(Ud[1])+exp(Ud[3]));
    2253 dP12=exp(Ud[2])/(exp(Ud[2])+exp(Ud[3]));
    2254 dP22=1;
    2255 dP13=exp(Ud[3])/(exp(Ud[2])+exp(Ud[3]));
    2256
    2257 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];
    2258 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];
    2259 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];
    2260
    2261 prob=prob + Prof*Prom*Prod*G[3]*fP*mP*dP;
    2262 end;
    2263 sum=sum*prob ;
    2264 end;
    2265 return(sum);
    2266 finish maxFunction;
    NOTE: Module MAXFUNCTION defined.
    2267
    2268 optn={1 2};
    2269 X=J(1,66,0);
    2270
    2271 call nlpcg(rc,xres,"maxFunction",X,optn);
    ERROR: (execution) Invalid subscript or subscript out of range.

    operation : [ at line 2181 column 16
    operands : DATA, Z, *LIT1035
    DATA 7948 rows 58 cols (numeric)

    Z 1 row 1 col (numeric)

    7949

    *LIT1035 1 row 1 col (numeric)

    5

    statement : ASSIGN at line 2181 column 1
    traceback : module MAXFUNCTION at line 2181 column 1

    ERROR: (execution) Invalid subscript or subscript out of range.

    operation : NLPCG at line 2271 column 1
    operands : *LIT1332, X, OPTN

    *LIT1332 1 row 1 col (character, size 11)

    maxFunction
    X 1 row 66 cols (numeric)

    OPTN 1 row 2 cols (numeric)

    1 2

    statement : CALL at line 2271 column 1
    2272 run;
    NOTE: Module MAIN is undefined in IML; cannot be RUN.
    2273 quit;
    NOTE: Exiting IML.
    NOTE: 299 workspace compresses.
    NOTE: SAS 系统由于错误而åœæ­¢äº†è¯¥æ­¥çš„处ç†ã€‚
    NOTE: “PROCEDURE IMLâ€æ‰€ç”¨æ—¶é—´ï¼ˆæ€»å¤„ç†æ—¶é—´ï¼‰:
    实际时间 1.81 秒
    CPU 时间 1.81 秒
     
    Yingan Lee, Aug 2, 2009
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.