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 (November 1999, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 29 Oct 1999 13:42:09 -0400
Reply-To:     Bob Burnham <Robert.A.Burnham@DARTMOUTH.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Bob Burnham <Robert.A.Burnham@DARTMOUTH.EDU>
Organization: Dartmouth College, Hanover, NH, USA
Subject:      Re: Log output to SAS code

Bruce Bradbury (remove XX) <B.BradburyXX@unsw.edu.au> wrote in message news:7valuo$d2j$1@mirv.unsw.edu.au... > Are there any macros available which take log file output (eg from the > MPRINT statement) and produce clean sas code? > >

I might be misunderstanding the question -- but if you are ever stuck in a situation where you only have a LOG file and want to recover the original SAS code that created it, something like this might help. It relies on the fact that the SAS log puts numbers in the first column followed by the code. As a result, this won't really work if you have in-line data using a CARDS statement.

/* Quick program to recover a SAS program from a log file.

Basic rules:

[1] Skip the first line (always a title) [2] Only keep lines with a number in the first column [3] If you find a page break, delete the next line */

%let nums=0123456789; %let spaces=12;

data _null_; length inLine $200; retain delNext 0; infile "old_program.log" truncover lrecl=200 firstobs=2; file "recovered_prog.sas" lrecl=200; input inLine $200.; fc = substr(inLine, 1, 1); if ((delNext = 0) and (indexc(fc, "&nums") > 0)) then do; inLine = substr(inLine, &spaces); put inLine; end; if indexc(inLine, '0C'x) then delNext = 1; else delNext = 0; run;

Vice versa, if you are on a UNIX system (or you happen to have some UNIX-type utilities installed), a much shorter sed script should get you pretty close:

# only keep lines beginning with a number /^[0-9]/!d # get rid of the number and extra spaces s/^[0-9]* \{1,12\}//

Best regards,

Bob


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