BookmarkSubscribeRSS Feed
CADSP
Calcite | Level 5

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

DataQTVenda
19/05/202035
20/05/2020234
21/05/202012
22/05/2020456
23/05/2020789
24/05/2020122
25/05/2020321
26/05/2020987
27/05/2020432

The first step would be to create two columns with QTVenda values ​​from 3 and 5 days ago, with reference to the line day.

DataQTVendad_3d_5
19/05/20203566112
20/05/202023425125
21/05/2020121266
22/05/20204563525
23/05/202078923412
24/05/20201221235
25/05/2020321456234
26/05/202098778912
27/05/2020432122456
28/05/2020 321789
29/05/2020 987122
30/05/2020 432321
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?

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Like this?

data WANT; 
  set HAVE;
  where DATA between today()-9 and today()+30 ;
  D_3=lag3(QTVenda);
  D_5=lag5(QTVenda);
run;

 

ChrisNZ
Tourmaline | Level 20

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;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 235 views
  • 0 likes
  • 2 in conversation