Lorem Ipsum
Lorem Ipsum

Reputation: 4524

Insert blank line after put or %put statement

I'm wondering, is there a simple way to insert a blank line after %put or put statement in the log without adding an extra put statement?

I use a lot of macros which write information to the log. The spacing on successive log statements, however, starts to look scrunched:

NOTE: [MACRO] Executing: Main()
NOTE: [MACRO] Executing: ImportData()
NOTE: [AUTOCALL] Executing: ExcelOpen(inFile=\\file\path\to\excelFile.xlsx)
NOTE: [AUTOCALL] Opening \\file\path\to\excelFile.xlsx...
NOTE: [AUTOCALL] Succesfully opened \\file\path\to\excelFile.xlsx.
NOTE: [AUTOCALL] EXCELOPEN macro used (Total process time):
              real time            02.30 seconds
NOTE: [MACRO] Executing: ImportMortalityData()
NOTE: [MACRO] Executing: ImportMortalityDay0ToDay7()
NOTE: [AUTOCALL] Executing: EstablishDDELink(fileRef=mort0_7,
dirData=\\file\path\to\, fileName=excelFile.xlsx, sheetName=Mortality (Day0-7), range=R2C1:R500C5)
NOTE: [AUTOCALL] DDE link MORT0_7 established.
NOTE: [AUTOCALL] ESTABLISHDDELINK macro used (Total process time):
              real time            00.27 seconds

I could insert an extra blank %put; or put; statement after each %put NOTE: or put NOTE: statement. However, that clutters up the code quite a bit and I want to avoid that.

In other languages, something like \r\n would be added to the end of the message, but SAS doesn't seem to have these constructs. I know there are the hex values 'OD'x (carriage returns) and 'OA'x (line feeds). Yet when I try to use them, they are printed as literals. Any ideas?

Upvotes: 0

Views: 6193

Answers (2)

Tom
Tom

Reputation: 51566

You need to use a separate %PUT to write a blank line. Note that you can replace the : with - in the NOTE:, WARNING: and ERROR: at beginning of the line if you want to keep the color coding in the SAS log without the clutter of the NOTE: text.

%macro xx;
%* write lines to the log ;
%put NOTE: [&sysmacroname] Starting. ;
%put NOTE- [&sysmacroname] Middle Note. ;
%put NOTE- %sysfunc(repeat(%str( ),%length(&sysmacroname)+1)) Middle Note Unlabeled. ;
%put ;
%put NOTE: [&sysmacroname] Ending. ;
%put ;
%mend xx;

enter image description here

Upvotes: 4

Quentin
Quentin

Reputation: 6378

For PUT statement, you can do it with a /, e.g.:

142  data _null_ ;
143    put "hi" / "mom" ;
144  run;

hi
mom

But I don't know of a way to do it with %PUT, other than adding a null %PUT statement.

The PUT statement knows about plenty of fancy stuff (/ , @, @@, delimiters, etc etc), mostly because it is for writing to files (in addition to the log). In comparison, since %PUT only writes to the log, it doesn't have all the options for fancy reporting stuff.

Upvotes: 2

Related Questions