BookmarkSubscribeRSS Feed
sasbeginner
Calcite | Level 5

Hi, I need help running this!

 

data A; 

do y=1 to 300; 

if y < 5 and (1<x<6) then do; 

do i=1 to 7; 

do while (y-i>0);

B=(1-A(y-i));

end;

end;

end;

end;

output; 

run;

 

So, I already have values for A(y) i.e. A(1), A(2),...A(300)

 

E.g. if y=4 then B= (1-A(4-1))*(1-A(4-2))*(1-A(4-3)) 

 

Thanks!

 

 

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

Can you post some test data in the form of a datastep, and what the output should look like.  I am not following you at all.  Where does the variable X come into this, as its not described or set anywhere?  Why the output statement at the end, its not needed.  I assume a() is an array, what does the array define?  Test data really helps.

Kurt_Bremser
Super User

First of all, your code yields a single error message:

 

ERROR 68-185: The function A is unknown, or cannot be accessed.

 

telling us that A() needs to be defined. Should it be an array, or is it a function defined elsewhere?

If it is a SAS array, it needs to be defined; it is also better to enclose the subscript in {}, making this more readable and clearer.

 

Once this is resolved, you will get a NOTE: about x being unitialized, which will cause the condition 1 < x < 6 to always be false, so your data step won't do anything at all (besides counting y to 300). B and i will stay missing in the dataset A.

So, where does x come from?

 

And what is the purpose of all this?

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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