I would like to write the source code to a pdf, before displaying the results of the code.
I can use a series of ods pdf text=""; statements, and insert new lines and spacing as needed, but is there a way to put pre formatted text, like with an html <pre> tag so that I do not have to add all the escape characters with newline and nbspace to the source code?
Thank you
PROC REPORT seems to work better at preserving the leading spaces.
ods pdf file='c:\downloads\code.pdf';
proc report data=code ;
column line code ;
define line / order ;
define code / style(column)=[font_face=courier asis=on];
run;
proc print data=code;
id line;
var code / style = [font_face=courier asis=on];
run;
ods pdf close;
Why not use PROC PRINT?
data code ;
infile cards truncover ;
line+1;
input code $char80. ;
format code $char80. ;
cards4;
proc print data=sashelp.class;
var name age;
run;
;;;;
ods pdf file='c:\downloads\code.pdf';
proc print data=code ;
id line;
var code / style(data)=[font_face=courier];
run;
ods pdf close;
PROC REPORT seems to work better at preserving the leading spaces.
ods pdf file='c:\downloads\code.pdf';
proc report data=code ;
column line code ;
define line / order ;
define code / style(column)=[font_face=courier asis=on];
run;
proc print data=code;
id line;
var code / style = [font_face=courier asis=on];
run;
ods pdf close;
That was very helpful, thank you.
I tweaked the report a bit to get the output from this :
to this:
proc report data=code style=blockprint;
column line code ;
define line / '' order noprint;
define code / '' style(column)=[asis=on];
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.