Date: Fri, 29 Jul 2005 14:57:37 -0700
Reply-To: David L Cassell <davidlcassell@MSN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: David L Cassell <davidlcassell@MSN.COM>
Subject: Re: Successively reading any new file present in the folder
Content-Type: text/plain; format=flowed
>I want to write a macro which:
>1. Successively reads any new file present in the folder. This input
>folder can be C:\temp\sasdata.
>2. The macro should delete the files(these can be csv or sas dataset
>files) which are present in the folder C:\temp\sasdata after the use or
>after the sas dataset is being created out of these files.
>3.Should support some error handling like - If there are any errors
>while creating the sas dataset out of the imported (csv.sas files) file
>the affected files should be copied into another folder say
>C:\temp\error, and also relevant entries to the above should be added
>to the log file.
>Any help is highly appreciated. If a sample code/macro is readily
>available it will save a lot of time and efforts.
 I don't think you should start out trying to do this in a macro.
Work without any macro programming at first. Look up the
features for handling wildcards and multiple input files that are in the
DATA step. You may not need more than a single DATA step to
read in al lyour files and generate a list of the file names.
 Don't think in terms of SAS when you're doing system admin
tasks. If you want this level of error-handling, then you'd better
think about doing the file creation/deletion/moving in a sysadmin's
language, like Perl. After all, how can you move a file if you can't
touch it? If you fail to read it, it's likely to be much harder to
delete it or move it or whatever. (Think about the privileges
involved for these tasks.)
 It's really not fair to ask SAS-L to do all this work for you unless
you're willing to do some of it first. Write some code to do each
of the tasks. Test it out and debug it. Then show us and ask
for pointers in improving it. We can at least see what the underlying
specs are for your tasks.
David L. Cassell
3115 NW Norwood Pl.
Corvallis OR 97330
Express yourself instantly with MSN Messenger! Download today - it's FREE!