- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I really appreciate your efforts however I was wondering that can't it be possible in input table in a data step?.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
To evaluate data with SAS, it must first be brought into SAS. First import, then use one of the methods suggested, then subset.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Alright, Thanks!.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If by 'input', you mean directly in the set(someoption = )statment, then no.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Got it, Thank you for your precious time!.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- « Previous
-
- 1
- 2
- Next »