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:         Thu, 20 Dec 2001 17:52:42 -0700
Reply-To:     Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Subject:      Re: Using sas to automate file editing.
Comments: To: seeliger@MERCURY.COR.EPA.GOV
Content-Type: text/plain; charset=us-ascii

If you specify only a variable name in the PUT statement, you'll get list format by default. List format left-aligns variables. Try

put @1 line;

That will force formatted mode, and the blanks won't be stripped:

----- 9 data _null_; 10 infile cards; 11 input; 12 line = _infile_; 13 put _infile_; 14 put line; 15 put line $80.; 16 put @1 line $80.; 17 put line $char80.; 18 cards;

blanks before this! blanks before this! blanks before this! blanks before this! blanks before this! -----

-- JackHamilton@FirstHealth.com Development Manager, Technical Group METRICS Department, First Health West Sacramento, California USA

>>> seeliger <seeliger@MERCURY.COR.EPA.GOV> 12/20/2001 4:09 PM >>> I'm interested in using SAS to change %include statements in a group of programs so that other people can use them without having to edit dozens of files by hand to reflect local directory structure.

Using the "PUT line;" statement in the code below causes all leading blanks and the first character of each line in the referenced file (if not a space) is eliminated, with trailing characters remaining. But using "PUT _infile_;" does not do this. Thus far the documentation has proven opaque with regards to changing this. Do any of you have a pearl of wisdom to share?

FILENAME fref '/home/seeliger/tempdir/sasprog.sas';

DATA _NULL_; LENGTH line $200; INFILE fref SHAREBUFFERS; FILE fref;

INPUT; line=_infile_; *{code to munge line here}; PUT line; *<--- but PUT _infile_ works; RUN ;

DATA _NULL_; filename fref clear; RUN;

No doubt my collegue from across the isle would suggest a solution like:

perl -e "s/%include \'\/home\/seeliger\/emap\/qa//%include \'d:\\emap\qa\\/gi" -p -i.bak *.sas

where my %include statements all look like

%include '/home/seeliger/emap/qa/somecode.sas';

However, I can't count on off-site people having perl available to them, and SAS is the only utility all users have in common, leading to my current 150+ line solution, reproduced in part above.

cur - The program that runs with the most lines wins, right?

-- 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