BookmarkSubscribeRSS Feed
Vasundha
Calcite | Level 5

Right

PeterClemmensen
Tourmaline | Level 20

If so, then try this

 

Data have;
Input in_date : date9. readings;
format in_date date9.;
Datalines;
04Nov2022 40
08Nov2022 89
09NOV2022 61
10NOV2022 60
11NOV2022 67
15NOV2022 45
16NOV2022 15
17NOV2022 12
18NOV2022 10
;
run;

data want;
  do p = max(1, n - 6) to n;
    set have nobs = n point = p;
    output;
  end;
  stop;
run;
Vasundha
Calcite | Level 5

I really appreciate your efforts however I was wondering that can't it be possible in input table in a data step?.

 

Vasundha
Calcite | Level 5

Alright, Thanks!.

PeterClemmensen
Tourmaline | Level 20

If by 'input', you mean directly in the set(someoption = )statment, then no.

Vasundha
Calcite | Level 5

Got it, Thank you for your precious time!.

Kurt_Bremser
Super User

Brute force approach:

proc sort
  data=have (keep=date)
  out=dates
  nodupkey
;
by descending date;
run;

data _null_;
set dates point=7;
call symputx("cutoff",date);
stop;
run;

data want;
set have;
where date ge &cutoff.;
run;

But the PROC RANK method is more efficient.