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 Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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