BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
393310
Obsidian | Level 7

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.

schatr2_1-1634938347232.pngschatr2_2-1634938421948.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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);
....

View solution in original post

4 REPLIES 4
data_null__
Jade | Level 19

You need the (index-variable) on the LHS of the = as you have on the right.

 

 categorical[j]=vvalue(categorical[j]);

 

Reeza
Super User

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);
....
393310
Obsidian | Level 7
Thank you so much!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2388 views
  • 0 likes
  • 4 in conversation