Quartz | Level 8

## how to find next 100th observation in time series

Hii Good morning.

the dates are starting from 1st jan2015 to 30sep 2015.

computing each date wise finding the next 100th obseravation.

example                     1st jan2015  doc1234   53

---------------------------

----------------------------

-----------------------------

after100th day is        4thApr2015  doc1234   87.

I want the output like 1st jan2015 Doc1234   53   4thApr2015   87.

this have to done in time series analysis in sas.

Any suggessions would be greatly recommended.

6 REPLIES 6
Barite | Level 11

## Re: how to find next 100th observation in time series

I am not sure if I have fully understood what you are after, but I think:

Data A (Drop=i);
Format Date Date9.;
Do i=1 To 200;
Date=IntNX('day','01JAN2015'd,i-1,'same');
Value=Round(Rannor(1)*5+50,1);
Output;
End;
Run;

Proc TimeData Data=A Out=_NULL_ OutArray=A (Where=(not Missing(Value2)) Drop=_:);
ID Date Interval=Day;
Var Value;
OutArray Date2 Value2; * I don't think you can insert a date format for Date2 here .. ;
Do t=1 To _LENGTH_;
Value2[t]=Value[t-100];
Date2[t]=Date[t-100];
End;
Run;

Data A;
Set A;
Format Date2 Date9.;
Run;

Barite | Level 11

## Re: how to find next 100th observation in time series

P.S. The Smiley isn't really a Smiley, but "Drop= :_ )".

Diamond | Level 26

## Re: how to find next 100th observation in time series

Can you post an example of test data in the form of a datastep, and required output.  It really isn't clear from your post what you expect.

Lapis Lazuli | Level 10

## Re: how to find next 100th observation in time series

Hello,

Have you considered the "LAG" function in SAS ? This should help with time series data...

http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/viewer.htm#etsug_tsdata_sect048...

Good luck...!!!

Kannan Deivasigamani
Lapis Lazuli | Level 10

## Re: how to find next 100th observation in time series

Another paper thought might help is attached.

Kannan Deivasigamani
Barite | Level 11

## Re: how to find next 100th observation in time series

If it's not dependent on date and you only want the 100th obs then this should do it:

data have;
infile cards dsd;
input field @@;
cards;
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,
.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
;

data all want;
set have;
count + 1;
if count = 101 then count = 1;
output all;
if count = 1 then output want;
run;

Discussion stats
• 6 replies
• 903 views
• 0 likes
• 5 in conversation