07-09-2014 09:59 PM
I came across a macro, and I believe I got the basic understanding of the program, but would like some confirmation.
length file $256 dye 8 dte1 8 directory $256;
format dte datetime;
keep file dye dte1 directory;
length filrf filerfb $8;
if opdir <=0 then put ‘ERROR: Unable to open log folder.’;
do i=1 to memcount;
dte=input (finfo(fid,’Create Time’),datetime.);
if dye >=&lastrun then output;
Would appreciate another pair of eyes, to help me understand this program.
Your help on this is greatly appreciated.
07-10-2014 05:57 AM
It looks like the program is indicating to go to a specified directory, check the files (possibly log files) and check the files for errors.
07-10-2014 11:40 AM
Hi, ... to add onto the previous comments...
And, the only possible reference to anything to do with SAS macro processing is this statement:
which may or may not be a reference to a SAS macro variable. Do you know whether &directory is a SAS macro variable? And if so, does this program even work? Can you find a statement where the value of &directory is set (such as a %LET statement or a CALL SYMPUT)? One thing that you could find out about referencing SAS Macro variables is that they will not resolve correctly unless they are enclosed in double (") quotes. So unless you are creating a literal string of '&directory' as the value for your directory data step variable, my suspicion is that your program is not working as you expect.
In addition, this may be problematic:
because usually the keyword DATA is separated from the dataset name by a space. So your code could be:
DATA logread; or DATA log read; depending on whether you were creating 1 dataset in the WORK library or 2. Or, I suppose that LOG could be your LIBRARY and this is a possibility: DATA LOG.READ; -- it really depends on what you expect to be the output of the program.
07-10-2014 02:38 AM
Actually this is not a macro at all, just a datastep that looks for files in given directory that were created after a given date, using the SAS file and directory I/O functions.
The directory name and the date are obviously specified somewhere farther "up" in the code.
To understand this, look at the documentation of the functions involved.
And there are a lot of syntax and semantic errors.
- datalogread should be data logread
- the format statement will not work, as the format spec is missing the dot
- dye is in the keep list and in a condition, but never has a value assigned (is always missing)