- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello lads,
I have the following data (just a small example):
Location -- Section -- Date -- Counts
Germany -- SA -- 29/04/2020 -- 20
Germany -- SA -- 28/04/2020 -- 67
Germany -- SA -- 27/04/2020 -- 34
Germany -- SA -- 26/04/2020 -- 56
Germany -- SB -- 29/04/2020 -- 76
Germany -- SB -- 28/04/2020 -- 43
Germany -- SB -- 27/04/2020 -- 44
Germany -- SB -- 26/04/2020 -- 90
The dataset contains data of more that 1 year back, it gets updated every day. I want to select just the counts of the last 30 days (per location and section!). Hope someone can help me out with this..
Thanks in advance 🙂
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
set have;
where date ge today() - 30;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
set have;
where date ge today() - 30;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@AK100 wrote:
I assume ge stands for Greater then or Equal?
Correct. The mnemonic for "greater" is gt. I like to use the mnemonics to avoid confusion when a certain character is not readily available on a keyboard, or might be changed somewhere along the way by some software converting it to a Unicode character.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I also tried to do the same for the past 3 months(not 90 days). I figured out the following code (with the help of one of your codes in some other topic):
data want;
set want;
where intnx('month',today(),-3,'same') <= datum <=today();
run;
I wondered if there was an easier code to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@AK100 wrote:
I also tried to do the same for the past 3 months(not 90 days). I figured out the following code (with the help of one of your codes in some other topic):
data want;
set want;
where intnx('month',today(),-3,'same') <= datum <=today();
run;
I wondered if there was an easier code to do this?
Using the INTNX function for this is the proper way, as it takes care of different month lengths. I see nothing wrong here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please post your data in usable form (data step with datalines), and the code you ran against it. I will test it and see what went wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content