Write and run SAS programs in your web browser

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

Reply
New Contributor
Posts: 3

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

I am doing a permutation test and i have gone as far as getting difference of the means using proc ttest. My next step is proc iml and thats where am stuck.

i keep getting the following error message on the log:

 

106         ods output off;

107 ods exclude all;
108 *borrowed code from internet ... randomizes observations and creates a matrix ... one row per randomization ;
109 proc iml;
NOTE: IML Ready
110 use pocketcash;
110 ! * change data set name here to match your data set name above;
111 read all var{school cash} into x;
WARNING: Variable cash excluded because of type mismatch with x.
111 ! *change varibale names here ... make sure it is class then var ... in that order.;
112 p = t(ranperm(x[,2],1000));
ERROR: (execution) Invalid subscript or subscript out of range.
 
operation : [ at line 112 column 17
operands : x, , *LIT1002
x 30 rows 1 col (character, size 8)
 
*LIT1002 1 row 1 col (numeric)

 

What am i doing wrong?

thanks

 

Super User
Posts: 17,784

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

Fix your errors in the order they come, since errors cascade. 

 

WARNING: Variable cash excluded because of type mismatch with x.

 

Fix this first, likely the variable 'cash' is character when it should be numeric. 

 

New Contributor
Posts: 3

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

No "cash" is numeric. and school is a character variable.

 

Super User
Posts: 17,784

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

Post the actual code you're referencing. Make sure it runs with their data and then switch to your data. 

New Contributor
Posts: 3

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

 

*borrowed code from internet ... randomizes observations and creates a matrix ... one row per randomization ;
 proc iml;                                                                                                                                                                                                                   
 use pocketcash;                        * change data set name here to match your data set name above;                                                                                                                             
 read all var{school  cash} into x;      *change varibale names here ... make sure it is class then var ... in that order.;                                                                                                 
 p = t(ranperm(X[,2],1000));            *Note that the "1000" here is the number of permutations. ;                                                                                                                                   
 paf = x[,1]||p;                                                                                                                                                                                                             
 create newds from paf;                                                                                                                                                                                                      
 append from paf;                                                                                                                                                                                                            
 quit;

 

Not sure why its posting with the breaks but i hope it makes sence to you,
 
                            

 

Ask a Question
Discussion stats
  • 4 replies
  • 178 views
  • 0 likes
  • 2 in conversation