BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
analyst_work
Obsidian | Level 7

Hi,

How do I indent a row in SAS RWI? the indent= ot textindent= options do not seem to work.

 

Thank you, 

Neha.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi:

  Leftmargin and rightmargin worked for me as style attribute overrides instead of trying indent=. Here's my output showing both the left margin and the right margin "indented" on selected rows, using conditional logic in the program:

leftmargin_works_to_indent.png

 

  And this is the program that created it.

 

options nodate nonumber;
ods pdf file="c:\temp\leftmargin_rightmargin_rwi.pdf" notoc ;
   
title '1) Use LeftMargin and RightMargin attributes';
data _null_; 
  set SASHELP.IRIS(obs=10) end=last; 
  if _N_ = 1 then do; 
      dcl odsout obj(); 
      obj.table_start(); 
        obj.head_start(); 
	    ** Header row 1;
          obj.row_start(type: "Header"); 
            obj.format_cell(text: "Species", 
                            style_attr:"fontweight=bold just=l width=2in leftmargin=.25in"); 
            obj.format_cell(text: "SepalLength", 
                            style_attr:"just=r fontweight=bold width=2in"); 
          obj.row_end(); 
        obj.head_end(); 
    end;
     ** row for every obs;
	 ** make every other row look "indented" by changing cell margin;
      obj.row_start(); 
	  if _n_ in (1,3,5,7,9) then do;
            obj.format_cell(data: species, style_attr:"just=l leftmargin=0in"); 
            obj.format_cell(data: SepalLength, style_attr:"just=r rightmargin=0in"); 
	  end;
	  else do;
            obj.format_cell(data: species, style_attr:"just=l leftmargin=.5in");
            obj.format_cell(data: SepalLength, style_attr:"just=r rightmargin=.5in"); 
	  end;
      obj.row_end(); 
   
  if last then do; 
      obj.table_end(); 
  end; 
run; 
ods pdf close;

  My memory ( which may be faulty) was that INDENT= was originally designed for RTF, but I always thought that leftmargin= worked better as an override.

 

cynthia

 

 

View solution in original post

3 REPLIES 3
ballardw
Super User

RWI is what?

Provide more of an example of what you are doing. If you are using a procedure to generate output some of the options only work for the tradional Listing output not in ODS (Html, RTF, PDF etc).

analyst_work
Obsidian | Level 7
Hi,

I am using the Report Writing Interface (RWI) to produce a table in which I
need to indent a column. The code is something like this:

obj.row_start();
obj.format_cell (text: "xyz");
obj.row_end;

I want to indent the text xyz, how should I do it?

Thank you.

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Cynthia_sas
Diamond | Level 26

Hi:

  Leftmargin and rightmargin worked for me as style attribute overrides instead of trying indent=. Here's my output showing both the left margin and the right margin "indented" on selected rows, using conditional logic in the program:

leftmargin_works_to_indent.png

 

  And this is the program that created it.

 

options nodate nonumber;
ods pdf file="c:\temp\leftmargin_rightmargin_rwi.pdf" notoc ;
   
title '1) Use LeftMargin and RightMargin attributes';
data _null_; 
  set SASHELP.IRIS(obs=10) end=last; 
  if _N_ = 1 then do; 
      dcl odsout obj(); 
      obj.table_start(); 
        obj.head_start(); 
	    ** Header row 1;
          obj.row_start(type: "Header"); 
            obj.format_cell(text: "Species", 
                            style_attr:"fontweight=bold just=l width=2in leftmargin=.25in"); 
            obj.format_cell(text: "SepalLength", 
                            style_attr:"just=r fontweight=bold width=2in"); 
          obj.row_end(); 
        obj.head_end(); 
    end;
     ** row for every obs;
	 ** make every other row look "indented" by changing cell margin;
      obj.row_start(); 
	  if _n_ in (1,3,5,7,9) then do;
            obj.format_cell(data: species, style_attr:"just=l leftmargin=0in"); 
            obj.format_cell(data: SepalLength, style_attr:"just=r rightmargin=0in"); 
	  end;
	  else do;
            obj.format_cell(data: species, style_attr:"just=l leftmargin=.5in");
            obj.format_cell(data: SepalLength, style_attr:"just=r rightmargin=.5in"); 
	  end;
      obj.row_end(); 
   
  if last then do; 
      obj.table_end(); 
  end; 
run; 
ods pdf close;

  My memory ( which may be faulty) was that INDENT= was originally designed for RTF, but I always thought that leftmargin= worked better as an override.

 

cynthia

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1896 views
  • 0 likes
  • 3 in conversation