BookmarkSubscribeRSS Feed
Calcite | Level 5
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;
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.
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.
Super User
This will only work for last submitted code.

Run> Recall Last Submit.

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.
Calcite | Level 5
Good reminder. It helps. Thanks!
Opal | Level 21
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.
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!
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 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 '' ;
put _infile_ ;
run ;

rough but ready
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.
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_;

Fluorite | Level 6
That Alt+LftMouseClk was very sweet, many thx!!
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.


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.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 13 replies
  • 9 in conversation