Hi:
Let me outline the issues with this and suggest some solutions.
So, let me address your various points:
Using your program sample to make some fake data, if you look at the data in a table viewer, you will see the leading spaces that you've added to the XYZ variable. However the ONLY destination that will show those leading spaces in the XYZ variable is the LISTING destination or the OUTPUT window as shown below in this example of PROC PRINT.
The LISTING window or LISTING destination or OUTPUT window is the original output location for procedure results. The destination is called a "monospace" destination because the letter i or the letter l take up the same amount of space on the line as the letter v or the letter w. So each character that you have in a variable value can be displayed in the LISTING results, as shown above. The LISTING destination or OUTPUT window will "respect" those leading spaces that you've pumped into the beginning of the variable value. In the PROC PRINT sent to the LISTING destination, the XYZ variable clearly looks indented only because the LISTING window works that way.
And, I can look at the data in a table viewer and see that xyz has been padded with leading spaces, as shown below:
But, even though I can see the leading spaces in the table viewer and the LISTING output, that does not ensure the output will be the same in other ODS destinations. For example, consider this output from the SAME program:
HTML
RTF
PDF
As you can see, the leading spaces do not get used at all when the PROC PRINT output is rendered by a browser (HTML), by WORD (RTF) or by Adobe Acrobat (PDF).
2. If your ultimate goal is RTF output -- this looks like an Adverse Event report. Most of my students from Pharmas generate RTF or PDF output for these reports -- then I would recommend using a style override for changing LEFTMARGIN using PROC REPORT in a COMPUTE BLOCK. The code for both #1 (PROC PRINT example) and #2 PROC REPORT example is pasted below:
options linesize=100 nocenter;
data final;
length aesoc $20 aedecod $35 xyz $100;
infile datalines dlm=',' dsd;
input aesoc $ aedecod $;
if aesoc=aedecod then xyz=aedecod;
else xyz=" "||aedecod;
datalines;
investigations,"investigations"
investigations,"Alanine aminotransferase"
;
run;
title; footnote;
ods listing;
ods rtf file="c:\temp\test_padding.rtf";
ods pdf file="c:\temp\test_padding.pdf";
ods html path="c:\temp" file="test_padding.html";
proc print data=final;
title '1) PROC PRINT with padding only works in LISTING destination';
var aesoc aedecod xyz;
run;
ods html close;
ods rtf close;
ods pdf close;
options center;
title; footnote;
ods rtf file="c:\temp\alt_style.rtf";
ods pdf file="c:\temp\alt_style.pdf";
ods html path="c:\temp" file="alt_style.html";
proc report data=final;
title '2) PROC REPORT with leftmargin works in RTF and PDF';
title2 'padding still works in LISTING. Neither approach works in HTML';
column aesoc aedecod xyz;
define aesoc / display;
define aedecod / display;
define xyz / display;
compute xyz;
if aesoc ne aedecod then do;
call define(_col_,'style','style={leftmargin=.25in}');
end;
else if aesoc eq aedecod then do;
call define(_col_,'style','style={font_weight=bold}');
end;
endcomp;
run;
ods html close;
ods rtf close;
ods pdf close;
title; footnote;
In order to run my program on the server, you'll have to change the locations in the FILE= and PATH= options. My guess is your server might not be a Windows server, so you'll have to find a server location where you have write access to create the files. The #1 program uses ODS LISTING and on Windows, this code populates the LISTING window for me. With SAS Studio on a server, you might have to use the FILE= option with #1 in order to write the results to an ASCII text file. However, since the leading spaces don't really work, if you're interested in producing RTF reports that you can open in Word or PDF reports that you can open in Adobe Acrobat, then I recommend just using the #2 example code and moving forward from there.
Hope this helps explain why it doesn't work and how you can achieve the indenting you want.
Cynthia
... View more