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

by yinganlee » Sun, 02 Aug 2009 09:48:51 GMT

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 f1*/
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 f1 */
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 m1*/
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 d1*/
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 f1,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: ROCEDURE IML:
1.81 CPU 1.81

Similar Threads

1. ERROR: Array subscript out of range

2. how to make "subscript" in a variable

Dear list

I have situation like in a SAS dataset i have to create a variable and
its value contains the special case as 'subscript' or 'superscript'
characters, can any one help me on this.

I do have some idea as: by using ODS ESCAPECHAR= ' ' am getting the
required in external files(XX.rtf , XX.pdf), but i want the same in
dataset value itself not in outputs.

i hope my doubt is clear.

Thanks in advance.


3. IF conditions and ARRAY subscripts

4. Displaying special characters as subscript or superscript using Report

Dear all,
         May be some SAS Guru can help me to solve this problem. Is it
possible to display Special character as superscript or subscript in
the report(in the TITLES,FOOTNOTES,FORMATS AND THE BODY) WITHOUT using
the ODS. I am using PROC REPORT. Immediate response will be highly
appericated.
Thanks
V

5. Computing array subscript

6. log10 print out with the 10 appearing in subscript

Greetings,

I'm working on a summary table that contains
log-base10 values, and I'd like to have log10 print
out with the 10 appearing in subscript. Would anyone know
the control code that does this? For example, ALT+0176
will output a degree symbol.

Thanks in advance.


Geri Akpan
SAS Programmer
973.401.0007 ext 214
 XXXX@XXXXX.COM 

7. subscripts in titles

8. Error statement and loop subscripts

What's going on here? I use the error statement for debugging
programs, but this behaviour had me confused for a bit. (version 9.1
TS1M2)

496  data _null_;
497  do i=1 to 10;
498    do j=1 to 3;
499      if i=3 then error;
500    end;
501  end;
502  run;

i=11 j=4 _ERROR_=1 _N_=1