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 (March 2002, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 5 Mar 2002 15:28:21 -0500
Reply-To:     Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject:      Re: Replacing a string in a file
Content-Type: text/plain; charset="iso-8859-1"

In fact, this is really a Word mail merge, right? Assuming I knew that Word would be available at run time, I'd have the original document generated as a mail merge template document, and then use SAS to generate the data file for the mail merge in the appropriate format. As Bill mentions, you could then automate the Word app from within SAS if you want.

Mike Rhoads Westat RhoadsM1@Westat.com

-----Original Message----- From: William W. Viergever [mailto:wwvierg@ATTGLOBAL.NET] Sent: Tuesday, March 05, 2002 2:58 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Replacing a string in a file

Hi David:

PMFJI, for I maybe way off base, but why don't you simply use DDE to open them in Word and effect your changes from w/i?

At 11:45 AM 3/5/2002 -0500, David L. Ward wrote: >Basically, recfm=N will disregard line breaks when reading data. This is >useful if you have either binary data or extremely long lines that you want >to be able to read using multiple input statements and not worry about >record length. With this format there are no "records", but the length of >the data you can read in one input statement is controlled using lrecl. >Thus in this case the trailing @ symbols won't make much difference since >there's no such thing as a record. > >But correct me if I'm wrong! I haven't looked at this stuff in several >years. The reason I'm doing this now is that I am still trying to use a >"template" for printing form data. A client has a word document we can save >either as RTF or PCL that needs substitutions made (like address, name, >etc.). We need to then send it to the printer in a server environment. > >David >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Robert >Virgile >Sent: Tuesday, March 05, 2002 11:37 AM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Re: Replacing a string in a file > >David, > >Maybe using recfm=N takes care of these issues ... I'm not familiar with it. >Two changes to consider: > >1. Add the truncover option to the infile statement: > > infile 'c:\temp\temp.txt' recfm=N truncover; > >If the incoming line contains fewer than 100 characters, the input statement >will take whatever is there. > >2. Hold the line with a trailing @ sign, so later iterations of the input >statement read from the same line: > > input chunk $char100. @; > > >Other infile statement options may help. One such option (I forget its >name) measures the length of the incoming data line. Another (lrecl=) may >be needed to access long incoming records. > >Like I said, I'm not familiar with recfm=N and its implications, but any of >the above tools may come into play. > >Good luck. > >Bob V. > > >-----Original Message----- >From: David L. Ward <dward@SASHELP.COM> >Newsgroups: bit.listserv.sas-l >To: SAS-L@LISTSERV.UGA.EDU <SAS-L@LISTSERV.UGA.EDU> >Date: Tuesday, March 05, 2002 10:49 AM >Subject: Replacing a string in a file > > > >Hi all, before I spend too much time on this, what is the best way to > >replace all occurrences of a string with another in a binary file? Assume > >we want v6 compatibility (200 char string limit). The complication that > >arises is that if you read the binary file in 200 character chunks, the > >boundary of your chunks may occur in the middle of the search string. >Plus, > >if your chunk is comprised of too many search strings, the replacements (if > >longer than the search strings) may make the length of the string longer > >than 200 characters. > > > >The file needs to be binary so don't assume I can solve this by doing > >line-based reading and writing. I'm trying to replace strings in a variety > >of file formats, PCL, RTF (which can be line based, I know, but I'd rather > >stick with an exact copy of the file just with the replacements), etc. > >Besides, binary data is like reading one LONG line. > > > >This is the blind-man's approach. There are many problems I won't point >out > >but I'm sure they will be obvious to most of you. > > > >data _null_; > > length chunk $200; > > infile 'c:\temp\temp.txt' recfm=N; > > file 'c:\temp\temp2.txt' recfm=N; > > input chunk $char100.; > > chunk=tranwrd(chunk,'Default','Replacement'); > > put chunk $char100.; > >run; > > > >Thanks for any help! > > > >David W

------------------------------------------------------------ William W. Viergever Voice : (916) 483-8398 Viergever & Associates Fax : (916) 486-1488 Sacramento, CA 95825 E-mail : wwvierg@attglobal.net ------------------------------------------------------------


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