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 (December 2001, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 21 Dec 2001 11:41:03 -0800
Reply-To:     seeliger <seeliger@MERCURY.COR.EPA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         seeliger <seeliger@MERCURY.COR.EPA.GOV>
Subject:      Re: Using sas to automate file editing.
In-Reply-To:  <241d3df4.0112210917.12753073@posting.google.com>
Content-Type: TEXT/PLAIN; charset=US-ASCII

There have been some pretty good suggestions as to how to get SAS to make changes to a text file. Since this needs to run on unix, windows, cp/m and whatnot, I can't use sed or perl. Increasing the blksize to 1024 in the infile statement does not work, at least locally. SAS tech support, and at least a couple of people here, have suggested writing changes to a temporary file and then copying it back over the initial file, which may be the ideal solution. Apparently SAS (on unix and dos at least) reads files as a stream rather than as discrete records, which messes up things for FPUT() and PUT.

The nice thing about these suggestions is that they've forced me to look at parts of SAS I've neglected.

However, Peter Crawford suggests that care and understanding are sufficient to make in-place editing possible. The code below is more or less along the lines he suggested, and it works (again, at least locally). I'm not sure messing about with _infile_ is such a good idea, even if it works, largely because I don't know quite how _infile_ is populated, or what it might be used for internally; hence using it seems 'careless'. Any thoughts?

%LET code_dir=d:\emap\code\; FILENAME fref '~/temp/test.test';

DATA _NULL_; LENGTH line $200; INFILE fref SHAREBUFFERS ;*blksize=1024; FILE fref; RETAIN rx;

IF(_N_=1) THEN DO; rx=RXPARSE( "`@1$w* '%'include $w+ (''''|'""') " || "['~']['/'](($c|'-')+'/')*" || "<($c|'.'|'-')+> (''''|'""') ';' "|| "<($c|'-'|$'-`~!@#$%^&* ()=+[]\{}|;:,.<>?')*> " || " TO '%INCLUDE ''&code_dir'=1''';' =2" ); END;

INPUT; line=_infile_; CALL RXCHANGE(rx,1,_infile_); PUT _infile_; *PUT @1 line $CHAR80.;

RUN ;

filename fref clear;

cur - for a regular expression, it sure looks constipated to me.

-- Curt Seeliger, Data Ranger CSC, EPA/WED contractor 541/754-4638 seeliger.curt@epa.gov


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