<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Indentation does not work in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803920#M316564</link>
    <description>&lt;P&gt;By default Proc Print will left just justify all character output and remove leading spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For some destinations, not all you would could use the STYLE override for the variable such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var xyz / style(data)=[ASIS=on];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But that doesn't work in every ODS destination.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use a different character that doesn't get treated the same as a space such as the ASCII Null character which in Windows is created by holding down the ALT key and then pressing 255 on the numeric key pad.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   input x $;
   length y $ 10;
   if x='abc' then y=x;
   else y='&amp;nbsp;&amp;nbsp;&amp;nbsp;'||x; /*These are ASCII null not spaces*/
datalines;
abc
pdq
;


proc print data=example   ;
  var x y;
run;&lt;/PRE&gt;</description>
    <pubDate>Thu, 24 Mar 2022 22:16:16 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-03-24T22:16:16Z</dc:date>
    <item>
      <title>Indentation does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803884#M316555</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am writing this code to create a new variable xyz with indentation. But indentation does not work when I print the data or make a report - what seems to be the problem? But if I see the dataset finalfinal1 in SAS view - indentation is there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data finalfinal1;&lt;BR /&gt;set finalfinal;&lt;BR /&gt;length xyz aedecod aesoc $200.;&lt;BR /&gt;if aesoc=aedecod then xyz=aedecod;&lt;BR /&gt;else xyz=" "||aedecod;&lt;BR /&gt;proc print data=finalfinal1;&lt;BR /&gt;var aesoc aedecod xyz ae2 subj2 ae3 subj3 ae4 subj4 ae5 subj5;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SharifUddin_0-1648150351967.png" style="width: 920px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69762i3C35C04661CAD263/image-dimensions/920x244?v=v2" width="920" height="244" role="button" title="SharifUddin_0-1648150351967.png" alt="SharifUddin_0-1648150351967.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 19:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803884#M316555</guid>
      <dc:creator>SharifUddin</dc:creator>
      <dc:date>2022-03-24T19:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Indentation does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803920#M316564</link>
      <description>&lt;P&gt;By default Proc Print will left just justify all character output and remove leading spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For some destinations, not all you would could use the STYLE override for the variable such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var xyz / style(data)=[ASIS=on];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But that doesn't work in every ODS destination.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use a different character that doesn't get treated the same as a space such as the ASCII Null character which in Windows is created by holding down the ALT key and then pressing 255 on the numeric key pad.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   input x $;
   length y $ 10;
   if x='abc' then y=x;
   else y='&amp;nbsp;&amp;nbsp;&amp;nbsp;'||x; /*These are ASCII null not spaces*/
datalines;
abc
pdq
;


proc print data=example   ;
  var x y;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Mar 2022 22:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803920#M316564</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-24T22:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Indentation does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803927#M316568</link>
      <description>Thanks. I tried ALT+255 - it does weird thing - delete the line where I try to put blank space using this.&lt;BR /&gt;&lt;BR /&gt;By the way I am using SAS Studio.&lt;BR /&gt;&lt;BR /&gt;This is really driving me crazy!&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Mar 2022 22:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803927#M316568</guid>
      <dc:creator>SharifUddin</dc:creator>
      <dc:date>2022-03-24T22:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Indentation does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803930#M316570</link>
      <description>&lt;P&gt;That is one of the "features" of using ODS output instead of plain old text. It is not PROC PRINT so much that is removing the leading spaces, but the destination formatting styles.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try PROC REPORT?&amp;nbsp; You should be able to right align columns in PROC REPORT using the DEFINE statement options.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 23:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803930#M316570</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-24T23:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Indentation does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803943#M316573</link>
      <description>&lt;P&gt;SAS studio on which operating system? Note that I did say "in Windows".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can build a similar string using hex characters, possibly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;y= repeat('A0'x,4)||x;&lt;/P&gt;
&lt;P&gt;the Repeat function will make a string of the first character repeated the number of times in the second parameter position. So that should place 4 null characters before x.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 00:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803943#M316573</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-25T00:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Indentation does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803951#M316576</link>
      <description>Thanks again. My machine operates in window but I am using server version from SAS. I do not know the technical details.&lt;BR /&gt;&lt;BR /&gt;Let me try with your new suggestion.&lt;BR /&gt;&lt;BR /&gt;Thank you again.&lt;BR /&gt;&lt;BR /&gt;Sharif&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Mar 2022 01:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/803951#M316576</guid>
      <dc:creator>SharifUddin</dc:creator>
      <dc:date>2022-03-25T01:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Indentation does not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/804077#M316612</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Let me outline the issues with this and suggest some solutions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; So, let me address your various points:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;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.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1648217572060.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69788i8C63B60305D74390/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1648217572060.png" alt="Cynthia_sas_0-1648217572060.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And, I can look at the data in a table viewer and see that xyz has been padded with leading spaces, as shown below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_1-1648217572061.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69789i04536E34D4518646/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_1-1648217572061.png" alt="Cynthia_sas_1-1648217572061.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;HTML&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_2-1648217572062.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69787iA1727FAEE1E90D56/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_2-1648217572062.png" alt="Cynthia_sas_2-1648217572062.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RTF&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_3-1648217572064.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69791i9783999BE14DB0A4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_3-1648217572064.png" alt="Cynthia_sas_3-1648217572064.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PDF&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_4-1648217572067.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69790i58D0C7EE854B71D3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_4-1648217572067.png" alt="Cynthia_sas_4-1648217572067.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, the leading spaces do &lt;STRONG&gt;&lt;U&gt;not&lt;/U&gt;&lt;/STRONG&gt; get used at all when the PROC PRINT output is rendered by a browser (HTML), by WORD (RTF) or by Adobe Acrobat (PDF).&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; 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:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps explain why it doesn't work and how you can achieve the indenting you want.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 15:27:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indentation-does-not-work/m-p/804077#M316612</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2022-03-25T15:27:08Z</dc:date>
    </item>
  </channel>
</rss>

