Help using Base SAS procedures

Extracting/Selecting observations of the last 20 mins of a SAS data set

Reply
N/A
Posts: 1

Extracting/Selecting observations of the last 20 mins of a SAS data set

Hey guys,

I hope anyone can help me on this.

I have a data set, which is continuously updated. For each observation, I have the time and date when the observations entered the data set. Currently I am calculating a number of metrics (means etc.) for the whole data set using a proc tabulate, which is working fine. However, I would like to perform my analysis not on the entire data set but only on the observations of the last 20 or 30 minutes from the moment, I request my metrics (System Time). Is there a way to include this restriction into a WHERE statement in the proc tabulate or is there a simple way to extract this time interval (last 20 min.) and create a new data set and then run the analysis?

Thank you guys.

Kind regards

Respected Advisor
Posts: 3,156

Re: Extracting/Selecting observations of the last 20 mins of a SAS data set

One possibility is to put WHERE condition as a data set option, somewhere like:

PROC TABULATE data=foo (WHERE=);

CLASS ...;

VAR ...;

TABLE ...;

RUN;

Super User
Posts: 7,771

Re: Extracting/Selecting observations of the last 20 mins of a SAS data set

Sort to a new dataset by descending time, then retain the time from _n_ = 1, and use a subsetting if with reference_time - 20*60 (as SAS time is stored in seconds)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 2 replies
  • 167 views
  • 0 likes
  • 3 in conversation