BookmarkSubscribeRSS Feed
HaTruong
Calcite | Level 5

 

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?

2 REPLIES 2
Astounding
PROC Star

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.

ballardw
Super User

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?

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
  • 1025 views
  • 0 likes
  • 3 in conversation