BookmarkSubscribeRSS Feed
FriedEgg
SAS Employee

Use double set with key lookup to account for missing dates, similar to my previous method using double set statements and point:

data foo(index=(date /nomiss /unique));
call streaminit(12345);
do date='01JAN1960'd to today();
  count=int(rand('uniform')*10e2);
  if rand('table',.95)=1 then output;
end;
format date date9.;
run;

data bar;
set foo(rename=(date=_date)) nobs=nobs;
sum=.;
miss=0;
do date=_date-10 by 1 while ( date < _date and _n_ > 10 /* and miss=0 */ );
  set foo key=date/unique;
  if _iorc_ then do;
   _iorc_=0;
   _error_=0;
   miss+1;
  end;
  else do;
   sum+count;
  end;
end;

*if miss>1 then call missing(sum);
date=_date;
drop _date;
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
  • 2162 views
  • 2 likes
  • 10 in conversation