Solution please

Accepted Solution Solved
Reply
Contributor
Posts: 39
Accepted Solution

Solution please

 

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
Grand Advisor
Posts: 10,211

Re: Solution please

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.

Add

ARRAY data_(18) data_1 - data_18;

to the code for CURR1 and you should be okay.

View solution in original post


All Replies
Contributor
Posts: 39

Re: Solution please

And i dont want to use Macros here .

Solution
‎10-29-2014 10:50 AM
Grand Advisor
Posts: 10,211

Re: Solution please

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.

Add

ARRAY data_(18) data_1 - data_18;

to the code for CURR1 and you should be okay.

Contributor
Posts: 39

Re: Solution please

Thank you Ballrdw, PaigeMiller.

Your suggestions are valuable... Smiley Happy

Trusted Advisor
Posts: 1,498

Re: Solution please

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_

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 202 views
  • 3 likes
  • 3 in conversation