DATA Step, Macro, Functions and more

need to create a Control table using which the file should be loaded to table

Reply
Contributor
Posts: 66

need to create a Control table using which the file should be loaded to table

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.

 

 

Super User
Posts: 19,772

Re: need to create a Control table using which the file should be loaded to table

Posted in reply to santosh_pat69

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.

Contributor
Posts: 66

Re: need to create a Control table using which the file should be loaded to table

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.";

 

 

 

 

Ask a Question
Discussion stats
  • 2 replies
  • 134 views
  • 0 likes
  • 2 in conversation