Help using Base SAS procedures

set start and end date for a time series but no interpolation

Reply
Super Contributor
Posts: 395

set start and end date for a time series but no interpolation

Hi, does anyone know how I can set a specified start date and an end date in a time series, but not inperolate like in using proc timeseries or proc expand.. So if I have a series that starts in Mar'2005, but my start date for all series I set it to Jan'2000, then all the series start at Jan'2000 and will have blanks for each month from Jan'2000 to Mar'2005.. I can do this in Proc Timeseries, but it also interpolates (in case if there are missing holes in between) which I don't want.   Thanks

Grand Advisor
Posts: 9,444

set start and end date for a time series but no interpolation

I don't understand what you mean totally.

What outpu do you like ?

If you only want a list of monthes.

data have;

do i=1 to 62;

  date=intnx('month','01jan2000'd,i);

  output;

end;

format date monyy.;

run;

Ksharp

Super Contributor
Posts: 395

Re: set start and end date for a time series but no interpolation

Ok, if each of my series (Store by Product, over 500 of them) has data from let's say Mar'2005 to Jun'2009, with Pricing data that has some holes in between.. I would like to extend that period from Jan'2000 to Dec'2011 with simply leaving the beginning (eg. Jan'2000 to Mar'2005) with blanks/missing, and the ends (eg.Jun'2009 to Dec'2011) also having missing data.. BUT, the original holes that are in between Mar'2005 and Jun'2009 to NOT be filled in or interploated.  Proc Timeseries allows to create the end (Jan'2000) and end (Dec'2011) , but the problem is that it also interpolates the holes in between Mar'2005 and Jun'2009.

I have figured a way around it, but it's a 2 step process..

Step 1. Use Proc Timeseries to create the time frame as a shell, with meaningless info.. then Step 2. just merge the original Mar'2005 to Jun'2009 using a BY group, wiht the shell in Step1.

So it's dooable, but I wondered if there's something quicker through either proc timeseries or proc expand..I think for Proc Expand I can Chose METHOD=NONE, but don't know how I can pick a start and end date..

thanks

Super User
Super User
Posts: 6,121

Re: set start and end date for a time series but no interpolation

Not sure what your data structure is.  But you can add extra observations where needed using something like this.

Assuming that GROUP identifies the the unique analysis groupings and DATE is your date variable (also asuming DATE is a SAS date variable).

data extra ;

   set have (keep=group date);

   by group;

   if first.group;

   date = '01JAN2000'd ;

   output;

   date = '01DEC2011'd ;

   output;

run;

data want ;

  merge extra have ;

  by group date;

run;

Super Contributor
Posts: 395

Re: set start and end date for a time series but no interpolation

Thanks Tom, I thought of a similar approach, but using proc timeseries.. I'll give yours a try.

Ask a Question
Discussion stats
  • 4 replies
  • 283 views
  • 0 likes
  • 3 in conversation