Hi all, I am struggling with my do loop. I continue to get "illegal reference to an array for the "categorical and npredictors" array, but it works just fine for my first array "var_list." Is there something that I am missing? I am using SAS 9.4. I also tried to run the arrays in separate data steps and it gave me the same error.
Variables can't have the same name as arrays.
I usually use _ in front of my arrays, as a coding standard it helps for sure.
array _categorical(*) ... ;
do .... ;
categorical = _categorical(i);
....
You need the (index-variable) on the LHS of the = as you have on the right.
categorical[j]=vvalue(categorical[j]);
You cannot have a non-array variable with the same name as the array.
Variables can't have the same name as arrays.
I usually use _ in front of my arrays, as a coding standard it helps for sure.
array _categorical(*) ... ;
do .... ;
categorical = _categorical(i);
....
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.