BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PeterClemmensen
Tourmaline | Level 20

Alternatively you can do this. It is not as efficient, but it ensures that every relevant year is actually present for each firm.  

 

data have;
length code $10;
code='one';
do year=2000 to 2015;
   cashflow=rand('integer', 1000, 10000);
   output;
end;
code='two';
do year=2000 to 2013;
   cashflow=rand('integer', 1000, 10000);
   output;
end;
code='three';
do year=2000 to 2015;
   cashflow=rand('integer', 1000, 10000);
   output;
end;
run;

proc sort data=have;
   by code;
run;

proc transpose data=have out=temp prefix=year;
    by code;
    id year;
    var cashflow;
run;

data want(keep=code year cashflow);
   set temp;
   array years{*} year2000-year2015;
   if nmiss(of years[*])=0 then do i=1 to dim(years);
      cashflow=years[i];
      year=input(compress(vname(years[i]), '0123456789', 'k'), 8.);
      output;
   end;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 15 replies
  • 1911 views
  • 3 likes
  • 4 in conversation