LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 26 Sep 2005 13:46:10 -0400
Reply-To:     Ya Huang <ya.huang@AMYLIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ya Huang <ya.huang@AMYLIN.COM>
Subject:      Re: Wildcard read in multiple files, some hurdles to overcome
Comments: To: Harry Droogendyk <harry.droogendyk@RBC.COM>
Content-Type: text/plain; charset=ISO-8859-1

Thanks Harry,

What about the very last file, can we get the 'stop of xx' right? Your code workd fine except for the last one.

eof options seems to conflict with eov or filename.

Ya

On Mon, 26 Sep 2005 13:10:16 -0400, Droogendyk, Harry <harry.droogendyk@RBC.COM> wrote:

>Doesn't look like EOV is reset once a new file is read. Use the value of XX and lag(XX) to detect changes: > >data _null_; >length xx yy zz $100; >retain zz yy; >infile 'c:\temp\file*.txt' filename=xx ;* eof=end; >file 'c:\temp\allfile.txt'; >input; > >prev_file = lag(xx); >yy=scan(xx,-2,'.\'); >if xx ne lag(xx) then do; > if _n_ > 1 then do; > yy=scan(prev_file,-2,'.\'); > put "##### Stop of " yy +(-1) ".txt #####"; > end; > zz=scan(xx,-2,'.\'); > put "##### Start of " zz +(-1) ".txt #####"; > end; >put _infile_; > >run; > >-----Original Message----- >From: owner-sas-l@listserv.uga.edu >[mailto:owner-sas-l@listserv.uga.edu]On Behalf Of Huang, Ya >Sent: Monday, September 26, 2005 1:01 PM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Wildcard read in multiple files, some hurdles to overcome > > >Hi there, > >The following code try to read in multiple ascii files, and >create a concatenate file. At the begining of each section, I >need to add a mark saying 'Start of xx file', and at the end >mark with 'Stop of xx file', where xx is the individual files >name. I'm having some trouble to get it done correctly. > >Any idea to fix it? > >Thanks > >Ya > >-------------- > >data _null_; >length xx yy zz $100; >retain zz yy; >infile 'c:\temp\xxx\*.txt' eov=newfile filename=xx ;* eof=end; >file 'c:\temp\allxxx.txt'; >input; >yy=scan(xx,-2,'.\'); > >if _n_=1 then put "##### Start of " yy +(-1) ".txt #####"; >if newfile=1 then do; >zz=scan(xx,-2,'.\'); >put "##### Stop of " yy +(-1) ".txt #####"; >put "##### Start of " zz +(-1) ".txt #####"; >end; >put _infile_; >* if end then put "##### Stop of " yy +(-1) ".txt #####"; >run; >___________________________________________________________________________ _______________________________________________________ > >This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. >Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. >If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. > >Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent. >Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné (s) est interdite. >Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.


Back to: Top of message | Previous page | Main SAS-L page