Solved
Contributor
Posts: 39

Here is my code i have curr dataset, where i have 18 variables with defined values lets say 180. I have to use these 18 variables in another dataset and derive another variable by depeding on this variable.

below is my code while using below code it was giving the error. can you please check and let me know how can i do this. Thanks in advance.

388 data curr1;

389 set curr;

390 ARRAY curr_(18) \$ curr_1 - curr_18;

391 do i = 1 to 18 by 1;

392 if data_{i} eq 180 then curr{i}='Y';

ERROR: Undeclared array referenced: data_.

ERROR: Variable data_ has not been declared as an array.

ERROR: Undeclared array referenced: curr.

ERROR: Variable curr has not been declared as an array.

393 end;

394 run;

And Here is the code.....

data curr;
ARRAY data_(18) data_1 - data_18;
DO I =1 TO 18 BY 1;
dat(I)=180;
END;
run;

data curr1;
set curr;
ARRAY curr_(18) \$ curr_1 - curr_18;
do i = 1 to 18 by 1;
if data_{i} eq 180 then curr{i}='Y';
end;
run;

Thank you,.

Accepted Solutions
Solution
‎10-29-2014 10:50 AM
Super User
Posts: 13,508

As the error says, you are attempting to reference an array you did not define: data_ in the data step that creates CURR1. Array is a temporary construct grouping variables in program code, it does not exist as an actual element of the data set.

ARRAY data_(18) data_1 - data_18;

to the code for CURR1 and you should be okay.

All Replies
Contributor
Posts: 39

And i dont want to use Macros here .

Solution
‎10-29-2014 10:50 AM
Super User
Posts: 13,508

As the error says, you are attempting to reference an array you did not define: data_ in the data step that creates CURR1. Array is a temporary construct grouping variables in program code, it does not exist as an actual element of the data set.

ARRAY data_(18) data_1 - data_18;

to the code for CURR1 and you should be okay.

Contributor
Posts: 39

Thank you Ballrdw, PaigeMiller.

Posts: 2,989

You defined the array to be named data_ (with the underscore on the end) so you have to refer to it later in the DO loop as data_

You defined the array to be named curr_ (with the underscore on the end) so you have to refer to it later in the DO loop as curr_

--
Paige Miller
🔒 This topic is solved and locked.