BookmarkSubscribeRSS Feed
mnew
Calcite | Level 5
Experts:
Is there a quick way to remove the log line numbers? In the example below, I'm hoping to remove the '483' ...without having to manually do it. Once a while I didn't save the codes but found them in the log files, then have to remove the numbers before I could submit the code again.
Thank you!
the lazy beginner

483 proc print data=work.Ptest;
484 format hired birth date7.;
485 run;
13 REPLIES 13
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
No SAS system options. Suggest using PROC PRINTTO (or CONFIG option ALTLOG= ) to re-direct the SAS-generated log to an external file and then use a SAS DATA step to INPUT and PUT the log contents, though you will also need to address SAS notes, warnings, maybe even errors, as well as possbly page-title info).

You may find that running SAS code from within a SAS macro may provide some limited relief, or at least different behavior, however don't expect the code to have line-breaks where you might normally expect.

Scott Barry
SBBWorks, Inc.
mnew
Calcite | Level 5
Got it. Thank you. Did not know I could have SAS send log to an external file...Also thanks for the second post. It is hard to teach a beginner, isn't it? Don't know what to do if you experts are not here.
Reeza
Super User
This will only work for last submitted code.

Run> Recall Last Submit.

HTH,
Reeza
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
And presumes you are running the SAS code interactively, if not already obvious from the last post-reply.

Scott Barry
SBBWorks, Inc.
mnew
Calcite | Level 5
Good reminder. It helps. Thanks!
SASKiwi
PROC Star
Here's another trick that can help with LOG files:

Get your log into the SAS editor using FILE/OPEN.

Press the ALT key and at the same time select the top left-hand corner of your log in the column just to the right of your line numbers by clicking with your mouse button. Now drag the mouse down to the bottom right-hand corner of your log. You should now have highlighted your SAS program without the line numbers.

You still have to do some tidying up to get rid of SAS messages but its a whole lot quicker than editing each line. This trick also works in the LOG window.
mnew
Calcite | Level 5
Very interesting and efficient solution. The first several times I tried, all the lines were selected (including line number). But later I pressed down Alt before clicking on the code and moved the mouse downward first then to the right, no line numbers were selected. Thank you!
Peter_C
Rhodochrosite | Level 12
and here is another
let SAS do the work
have a SAS program
1 open/read that log,
2 recognise relevant lines start with a number
3 open an output.sas.txt file
4 strip the log line number out of the log line
5 write what is left of the log line
data _null_ ;
infile 'C:\Applications\UK.Liquidity2\altlogs\461.log' ;
input @ ;
if _infile_ ne ' ' ; * not blank ;
if '0' < substr( _infile_,1,1) <= '9' ; * begins with number ;
num_end = index( _infile_, ' ' ) ; * find blank ;
_infile_ = substr( _infile_, num_end ) ; * take rest of line ;
file 'output.sas.txt' ;
put _infile_ ;
run ;

rough but ready
mnew
Calcite | Level 5
Thank you for sharing the magic! Not only removed the log numbers but also the SAS messages etc. In other words, the output file only keeps the codes I submitted. BTW, thanks for introducing me to the _infile_, and all the comments you added in to help out the beginner.
wkingc
Calcite | Level 5

I stumbled upon this code, but was unable to get it to work.  I am guessing since 2010 the syntax has changed a bit.  In any case here is an update in case anyone needs to do this:

data _null_;
   infile 'C:\FillMeIn\test.log';
   input @;;

   if _infile_ ne ' '; * not blank ;
   if '0' < substr(_infile_,1,1) <= '9'; * begins with number ;
   num_end = index(_infile_, ' '); * find blank ;
   _infile_ = substr(_infile_, num_end); * take rest of line ;

   file 'C:\FillMeIn\test_no_line_numerbers.log';
   put _infile_;
run;

dknochen
Fluorite | Level 6
That Alt+LftMouseClk was very sweet, many thx!!
PGStats
Opal | Level 21

You may also open your log file with a good programing editor like Notepad++, select the section that you want and use the command Delete line numbers or first word.

PG

PG
jjl
Calcite | Level 5 jjl
Calcite | Level 5

I pasted into Excel, using the text import wizard I set the fixed width so it made a column break after the line number, then I simply copied the second column.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 12584 views
  • 9 likes
  • 9 in conversation