SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AK100
Pyrite | Level 9

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 🙂

1 ACCEPTED SOLUTION
10 REPLIES 10
AK100
Pyrite | Level 9
Thank you 🙂
AK100
Pyrite | Level 9
I assume ge stands for Greater then or Equal?
Kurt_Bremser
Super User

@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.

AK100
Pyrite | Level 9
That makes sense 🙂
AK100
Pyrite | Level 9

@Kurt_Bremser 

 

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?

Kurt_Bremser
Super User

@AK100 wrote:

@Kurt_Bremser 

 

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.

AK100
Pyrite | Level 9
Oke, it works but sometimes when i change -3 in -10 for example (to give me pas 10 months) it still gives me only the past 3. Weird...
AK100
Pyrite | Level 9
I'm figuring out how to fix that datastep, hope to have it soon 🙂

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 4249 views
  • 2 likes
  • 2 in conversation