BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SteelersPitts
Obsidian | Level 7

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. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

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.

SteelersPitts
Obsidian | Level 7

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 854 views
  • 1 like
  • 2 in conversation