Date: Tue, 1 Jul 2008 04:40:07 -0700
Reply-To: Ben <ben.dray@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ben <ben.dray@GMAIL.COM>
Organization: http://groups.google.com
Subject: Re: Problems identifying newest version
Content-Type: text/plain; charset=ISO-8859-1
Thanks for the reply Michael, I should have stated in my original
message though that the .txt files aren't created in SAS - they come
out of a commercial program that churns them out as summary reports.
Thanks
Ben
On Jun 30, 7:44 pm, michaelrait...@WESTAT.COM (Michael Raithel) wrote:
> Dear SAS-L-ers,
>
> Ben posted the following:
>
>
>
> > I had a load of .txt reports each named arbitrarily that I
> > need to read in. My problem is that any corrections made to
> > the source data leads to a new randomly named .txt being
> > created (the out-of-date report is not deleted).
>
> > I'm able to read in all these .txt files fine but need some
> > way of just keeping the newest revisions for each
> > patient/visit. I'm assuming the only way to do this would be
> > to partially read in each file for the identifying
> > patient/visit data and then (hopefully) add in the 'created
> > date' information of the .txt file so that I am able to sort
> > them and keep the newest. Is there some way of doing this?
>
> Ben, are you allowed to delete files from this directory? If so, I
> would consider doing something like the following:
>
> 1. When you read in a .txt file and update it, write it out with a
> slightly different name.
> 2. After successfully creating the updated file:
> 2.A delete the original file.
> 2.B rename the new file to the name of the original file.
>
> I do something like that in the DATA _NULL_ step:
>
> **********************************************************;
> * Build DOS commands to delete original file and rename *;
> * new file to old file name. *;
> **********************************************************;
> data _null_;
>
> doublequote = '"';
>
> deletefile = "del " || doublequote || "&DIRNAME\&HTMLPAGE" ||
> doublequote;
>
> call system(deletefile);
>
> renamefile = "rename " || doublequote || "&DIRNAME\Z&HTMLPAGE" ||
> doublequote
> || " " || doublequote || "&HTMLPAGE"|| doublequote;
>
> call system(renamefile);
>
> run;
>
> ...ripped from the heart of Example 1 in my SAS Global Forum 2008 paper:
>
> Powering Your Organization's Web Applications With SAS(r) Software
> <<http://www2.sas.com/proceedings/forum2008/012-2008.pdf>>
>
> Check it out... Unless a better idea comes 'round.
>
> Ben, best of luck in all of your SAS endeavors!
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Michael A. Raithel
> "The man who wrote the book on performance"
> E-mail: MichaelRait...@westat.com
>
> Author: Tuning SAS Applications in the MVS Environment
>
> Author: Tuning SAS Applications in the OS/390 and z/OS Environments,
> Second Editionhttp://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=58172
>
> Author: The Complete Guide to SAS Indexes
> http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=60409
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Not even the gods fight against necessity. - Simonides
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|