Help using Base SAS procedures

how to find next 100th observation in time series

Reply
Frequent Contributor
Posts: 111

how to find next 100th observation in time series

Hii Good morning.

 

I have  a dataset in that variable are date,documentname, downloads.

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.

Super Contributor
Posts: 340

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

Posted in reply to Ravikumarkummari

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=_Smiley Happy;
  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;

Super Contributor
Posts: 340

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

Posted in reply to user24feb

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

Super User
Super User
Posts: 7,965

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

Posted in reply to Ravikumarkummari

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.

Regular Contributor
Posts: 161

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

Posted in reply to Ravikumarkummari

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
Regular Contributor
Posts: 161

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

Another paper thought might help is attached.

Kannan Deivasigamani
Valued Guide
Posts: 860

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

Posted in reply to Ravikumarkummari

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;

Ask a Question
Discussion stats
  • 6 replies
  • 382 views
  • 0 likes
  • 5 in conversation