BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jacksonan123
Lapis Lazuli | Level 10

I get the following error with the code:

ERROR 124-185 when macro with array is invoked more than once in DATA step.  I have read the post but I don't quite understand how it applies to my code. The specific log is:

 

[90 array subn(*) subn1-subn34;
____
124
ERROR 124-185: The variable subn has already been defined.
 
91 do i=1 to 34;
92 SUBJ(i)=1/(1+exp(-subn(i)));
____
68
ERROR 68-185: The function SUBN is unknown, or cannot be accessed.]
 
I need to know how to interpret and correct the error in my code since data test2 will not run but test1 runs just fine?
 
data test;
input   param $  sub1  treat $ subn  ;
cards;
logit -1.11 ates -0.03
logit -1.11 bref -0.03 
ka2 -0.50  bref -0.01
ka2 -0.50 ates -0.01
;
run;


data test1;
set test;
if Param in(  'logit' );
array subj(*) subj1-subj34;
array sub(*) sub1-sub34;
do i=1 to 34;
subj(i)=1/(1+exp(-sub(i)));

end;
run;
RUN;

data test2;
set test;
if Param in(  'logit' );
array subj(*) subj1-subj34;
array subn(*) subn1-subn34;
do i=1 to 34;
SUBJ(i)=1/(1+exp(-subn(i)));
end;
run;
RUN;

   

1 ACCEPTED SOLUTION
3 REPLIES 3
novinosrin
Tourmaline | Level 20

Hi @jacksonan123  You have a variable in your Input dataset named SUBN. Therefore that causes a conflict with your 2nd array name at compile time in TEST2

 

5655  data test2;
5656  set test;
5657  if Param in(  'logit' );
5658  array subj(*) subj1-subj34;
5659  array subn(*) subn1-subn34;run;
            ----
            124

ERROR 124-185: The variable subn has already been defined.

Please choose a different array name.

jacksonan123
Lapis Lazuli | Level 10
I have tried that in the past and I changed it to:

Data test2;

Set test;

..

Array subx(*) subx1-subx34;

..

Subj(i)=1/(1+exp(-subx(i)));

But my answer is

Test 1

Param sub1 treat subn subj1

Logit -1.11 ates -0.03 0.24

Test2

Param sub1 treat subn subj1

Logit -1.11 ates -0.03 .

The test2 should have the result from the calculation
Subj(i)=1/(1+exp(-subx(i)));

However I get a (.) for subj1 (i.e., no calculation value missing), but the
same code does give the correct answer for Test1.

That is what I need to know why so Test2 can be corrected.


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
  • 3 replies
  • 1111 views
  • 0 likes
  • 3 in conversation