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?

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 966 views
  • 0 likes
  • 3 in conversation