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);
....
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.