Dear all, The subject I wrote seem a bit unclear; however, what I want to ask is very simple. What I'm trying to do is to cut a certain period of dataset with the same number of observations, around a certain reference point. For example, the following is how my dataset looks: data work.item_output;
infile datalines truncover;
input date: yymmddn8. volume;
;
datalines; 20190101 30; 20190103 40; 20190104 25; ... 20190302 20; 20190304 20; 20190706 10; What I want to do is to take a reference date, say, 20190203, and extract the data containing of observations around that date, for example (-5 days) ~ (+5 days). And repeat this process for other reference dates as well. But, as you can notice, the date variable is not always present. For example, there are 20190101 and 20190103 observations, but there isn't 20190102, and I want to count simply by the number of observations, not by the actual date. So, for example, if I take +5 days data from 20190101, it would look something like this: 20190101 -> reference point 20190103 20190104 20190105 20190106 20190107 -> +5 days after the reference point So, by saying '+5 days,' I'm actually meaning '+5 observations.' And I want to extract that certain period of data as a separate dataset table in sas. For now, since I don't know how to make sas do this job automatically, I manually opened the original table, looked for the reference points, looked for the date that's 5 observations away from the reference point, copied that and extract that period of data manually by using data procedure. However, it is too time-consuming and burdensome because there are more than just one or two reference periods. So, I'd be great to know how to code this to work automatically (at least less manually than what I did), if there is a way to do so. I hope what I wrote made sense. It'd be great if anyone can help me out with this.
... View more