BookmarkSubscribeRSS Feed
IplaywithSAS
Calcite | Level 5

Hello,

 

I very recently started using SAS and one of the daily tasks I have is basically go through every single project and update the primary tables and run the project.

I was wondering if there is a way to automatically run the project with the most recent table available, for example:

 

I have table Cars_2021_09_01 where the project is collecting data. So since the month changed a new table was created name Cars_2021_10_01. Currently I have to open the project and manually change the previous table with the new table. Is there a way to do that automatically? 

 

Thanks for the help 🙂

2 REPLIES 2
SASKiwi
PROC Star

Is the date you want to process related to the date you run the project? For example if you run your project during September you want to read Cars_2021_09_01 and if you run during October you want Cars_2021_10_01? If so you can make use of the SAS TODAY function to read today's date and then automatically read the table you want.

data _null_;
  Table_Name = 'Cars_' !! translate(put(intnx('MONTH',today(), 0, 'BEGIN'), yymmddd10.), '_', '-');
  put _all_;
run;

 

Kurt_Bremser
Super User

So you have a library where all those datasets reside. Let's call this library IN for the example.

Within that library you have several datasets starting with CARS_, thankfully sorted by date because you use (commendable!) a YMD order.

Basically, you can retrieve the name of the most recent dataset like this:

proc sql noprint;
select max(name) into :dsname
from dictionary.tables
where libname = "IN" and memname like 'CARS_%';
quit;

After that use &dsname. wherever you need the source dataset.

 

Note that libname and memname in the dictionary tables are always uppercase for SAS datasets/views.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 662 views
  • 0 likes
  • 3 in conversation