DATA Step, Macro, Functions and more

array and lead function

Reply
Established User
Posts: 1

array and lead function

[ Edited ]

 

I try to use lead function to create many variables, so I do:

 

data reptrade.than1b;
           set reptrade.goc1;
array rett [10] rett1-rett10;
array eof [10];
do i=1 to dim(rett);
           if eof[i]= 0 then set reptrade.goc (firstobs= i+1 keep=ret rename=(ret=rett[i])) end=eof[i];
           else rett [i]=0;
end;
run;

 

 

but it doesn't work. the log file shows that the firstobs is wrong and lead[ is also wrong. anyone can help me?

Super User
Posts: 5,504

Re: array and lead function

Is this your intention?

 

Observations 1 through 61 contrihute to the first observation in the new data set.

 

Observations 2 through 62 contribute to the second observation in the new data set.

 

Follow the pattern, but zero-fill if you run out of observations.

Super User
Posts: 11,343

Re: array and lead function

[ Edited ]

When you have errors it helps to show the code and error or other messages from the log.

 

"Doesn't work" is kind of a vague description of what happens. Is the data set not created? Errors? Unexpected or incomplete data?

Ask a Question
Discussion stats
  • 2 replies
  • 436 views
  • 0 likes
  • 3 in conversation