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!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2208 views
  • 0 likes
  • 4 in conversation