Hi guys,
First excuse my english.
I am new to the SAS world, and I have a project to try to develop. I have doubts about where to start, or what issues to look for to solve it.
What I have:
A table from a server that I remove with proc sql, with the daily variables: Data, QTVenda
Data | QTVenda |
19/05/2020 | 35 |
20/05/2020 | 234 |
21/05/2020 | 12 |
22/05/2020 | 456 |
23/05/2020 | 789 |
24/05/2020 | 122 |
25/05/2020 | 321 |
26/05/2020 | 987 |
27/05/2020 | 432 |
The first step would be to create two columns with QTVenda values from 3 and 5 days ago, with reference to the line day.
Data | QTVenda | d_3 | d_5 |
19/05/2020 | 35 | 66 | 112 |
20/05/2020 | 234 | 25 | 125 |
21/05/2020 | 12 | 12 | 66 |
22/05/2020 | 456 | 35 | 25 |
23/05/2020 | 789 | 234 | 12 |
24/05/2020 | 122 | 12 | 35 |
25/05/2020 | 321 | 456 | 234 |
26/05/2020 | 987 | 789 | 12 |
27/05/2020 | 432 | 122 | 456 |
28/05/2020 | 321 | 789 | |
29/05/2020 | 987 | 122 | |
30/05/2020 | 432 | 321 | |
31/05/2020 | 987 | ||
01/06/2020 | 432 |
After that, I will use an accounting calculation for the QTVenda value of 28-05-2020 (current day) that takes into account d_3 and d_5. E I need this table to be updated with the calculated values of QtSale, d_3 and d_5, up to 30 days ahead of today, in the example it would be 27-06-2020. So that every day I run the code and the table always updates to start 9 days before today and end 30 days after today.
Which features of SAS Guide 7 can I use to try to do this?
Like this?
data WANT;
set HAVE;
where DATA between today()-9 and today()+30 ;
D_3=lag3(QTVenda);
D_5=lag5(QTVenda);
run;
Or maybe
data WANT;
set HAVE;
where DATA between today()-9-5 and today()+30 ;
D_3=lag3(QTVenda);
D_5=lag5(QTVenda);
if DATA > today()-9 ;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.