DATA Step, Macro, Functions and more

Weekly Data Read

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

Weekly Data Read

Hello All,

 

I've started some basic coding with SAS and need help from the group on the following:

 

Requirement:

1. Every Monday, I've to run a SAS script to read SAS data set for the last week (Sunday to Saturday) and append to a master table, XYZ. Every Monday, last week's data needs to be extracted and appended to the master table XYZ

2. The dataset is stored as sas dataset with daily time stamp (so that I know which data row belongs to what date). Example - Sales20180701.sas7bdat, Sales20180702.sas7bdat and so on

 

Question:

How can I read the dataset every Monday for the last week and then append it to a Master table, XYZ with a datestamp?

 

I apologize if the question is very basic. Thanks. 

 

 


Accepted Solutions
Solution
Wednesday
Super User
Posts: 10,284

Re: Weekly Data Read

Posted in reply to SteelersPitts

Run a do loop from today() - 8 to today() - 2. Format these dates with yymmddn8. and use them to build a string with the dataset names (separated by blanks). After the loop, use call symput to create a macro variable. Use that macro variable in the set statement of a data step to concatenate all datasets.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
Wednesday
Super User
Posts: 10,284

Re: Weekly Data Read

Posted in reply to SteelersPitts

Run a do loop from today() - 8 to today() - 2. Format these dates with yymmddn8. and use them to build a string with the dataset names (separated by blanks). After the loop, use call symput to create a macro variable. Use that macro variable in the set statement of a data step to concatenate all datasets.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 24

Re: Weekly Data Read

Posted in reply to KurtBremser

Thank you. I will let you know my coding result. Appreciate your help. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 59 views
  • 1 like
  • 2 in conversation