Right
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;
I really appreciate your efforts however I was wondering that can't it be possible in input table in a data step?.
To evaluate data with SAS, it must first be brought into SAS. First import, then use one of the methods suggested, then subset.
Alright, Thanks!.
If by 'input', you mean directly in the set(someoption = )statment, then no.
Got it, Thank you for your precious time!.
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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.