BookmarkSubscribeRSS Feed
santosh_pat69
Quartz | Level 8

Hi All,

 

I trying to automate a process to read an external file.

I recieve a file on a monthly basis, 4-7 days before the start of the New month.

for E.g : the Sales file for the month for April 2017 will be recieved anywhere between 25-31 march.

currently we are reading the file by manualy changing the filenames, and not running this piece of code if we dont have any updates or untill we recieve the New sales file for the next month.

I am listing all the files from the directory and creating a temp datasets which stores all teh files details and from these files i amextracting the date (the filename looks like this : Mnthly_Sales_201702.csv) and sorting the dataset and creating a macro for the recent Sales files.

Now the problem is this file has to be loaded once every month if there are no updates.

Please help me on this.

 

 

2 REPLIES 2
Reeza
Super User

@santosh_pat69 wrote:

Hi All,

 

 

I am listing all the files from the directory and creating a temp datasets which stores all teh files details and from these files i

 


If you can list all the files, you can use that to dynamically determine which dataset you need to process. 

The steps appear correct, what exactly do you need help with, your question is unclear.

santosh_pat69
Quartz | Level 8

Hi Reeza,

 

Apologies for being unclear.

The Job runs daily, if thereare updates or if we have new file the external file needs to read into SAS and other reports need to be generated.

if there are no updates or do not have a new file then the process should exit and continue the other process.

%let dir1 = "/d:/sales/";

data _Null_;

x "&dir1.";

x "find -maxdepth 1 -type f -mtime -7 -print > \D:\Santosh\Cmp.txt";

run;

 

Data _Null_;

Set filelist; *is the dataset consists the list of files ;

Call Symput('Lst_Rn_Dte', fl_dte);

Call symput("Today",put(intnx("day",today(),0),yymmn8.));

Run;

%put        "today ====>&today.";

%put "Lst_Rn_Dte===>&Lst_Rn_Dte.";

/*I need help on this i would like to execute this only if we have a new file or an update on the file else exit this process and continue with processing for other files we need to read the external file in advance.*/

%if %sysevalf (&Lst_Rn_Dte.) LE %SYSEVALF(&today.) %then

%do;

%put Note:"No File Avaialble.";

 

 

 

 

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
  • 1133 views
  • 0 likes
  • 2 in conversation