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

I have a data table which is already aggregated the way I want it for PROC REPORT.  I am only using PROC REPORT for the formatting and overall appearance of the report itself.  Below is my code.  Row is simply the row number in the table and is not outputted, Name is a descriptive text field, and the other fields are numeric values.  There are 35 rows of data in the input data set.  In the report,   I want to add a Line of text after row 5, after row 12 and after row 33 (say: "GROUP A", "GROUP B", "GROUP C" respectively).  I want the lines of text to stretch across all columns.  

 

I was able to successfully format rows as either percents, dollars, or numeric comma formats.  However, I cannot find any formatting scheme for indentation of the values in the cells.  I want this formatting to apply to all displayed columns (NAME, COL1, COL2, COL3, COL4).  I want 3 levels of indentation: 1 where the number value is all the way to the left of the cell, another which is spaced a little more to the right, and another spaced a little more to the right from that.  

 

proc report data=FINAL_Table
  STYLE(report)=[frame=box rules=cols]
     style(header)={borderbottomwidth=2pt borderbottomcolor=black};
column row NAME  COL1 COL2 COL3 COL4;


define row /order order =data noprint;
define Name/display style(column)={borderrightcolor=black borderrightwidth=3};
define COL1/display style(column)={borderrightcolor=black borderrightwidth=3};
define COL2/display style(column)={borderrightcolor=black borderrightwidth=3};
define COL3/display style(column)={borderrightcolor=black borderrightwidth=3};
define COL4/display style(column)={borderrightcolor=black borderrightwidth=3};

compute COL4;
      if row = 5 then do;
         do i = 3 to 6; 
            call define(i,'format','PERCENT8.1'); 
         end;
end; 
	  if row < 5 then do;
         do i = 3 to 6; 
            call define(i,'format','Comma12.0'); 
         end;
		 end;
      if row >5 then do;
         do i = 3 to 6; 
            call define(i,'format','DOLLAR12.2'); 
         end; 
		 end;
     
   endcomp;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
RichardDeVen
Barite | Level 11

Use LEFT option in column definition, and the PRETEXT= style attribute in the style.  The pretext will be hard spaces ("A0"x lead).

Example:

define COL1/display style(column)={borderrightcolor=black borderrightwidth=3} LEFT;
define COL2/display style(column)={borderrightcolor=black borderrightwidth=3 pretext="A0A0A0"x} LEFT;
define COL3/display style(column)={borderrightcolor=black borderrightwidth=3 pretext="A0A0A0A0A0A0"x} LEFT;
define COL4/display style(column)={borderrightcolor=black borderrightwidth=3 pretext="A0A0A0A0A0A0A0A0A0"x} LEFT;

 

You can also set the pretext conditionally in the compute block with CALL DEFINE(col, 'STYLE', ...).

Example:

call define (4, 'style', 'style=[pretext="A0A0A0"x]');  * lead cell value with 3 hard spaces;

View solution in original post

6 REPLIES 6
RichardDeVen
Barite | Level 11

Use LEFT option in column definition, and the PRETEXT= style attribute in the style.  The pretext will be hard spaces ("A0"x lead).

Example:

define COL1/display style(column)={borderrightcolor=black borderrightwidth=3} LEFT;
define COL2/display style(column)={borderrightcolor=black borderrightwidth=3 pretext="A0A0A0"x} LEFT;
define COL3/display style(column)={borderrightcolor=black borderrightwidth=3 pretext="A0A0A0A0A0A0"x} LEFT;
define COL4/display style(column)={borderrightcolor=black borderrightwidth=3 pretext="A0A0A0A0A0A0A0A0A0"x} LEFT;

 

You can also set the pretext conditionally in the compute block with CALL DEFINE(col, 'STYLE', ...).

Example:

call define (4, 'style', 'style=[pretext="A0A0A0"x]');  * lead cell value with 3 hard spaces;
RandoDando
Pyrite | Level 9
I want the indentation formatting to be by specific rows, not columns.
RichardDeVen
Barite | Level 11
Use CALL DEFINE conditionally in the COMPUTE block.
RandoDando
Pyrite | Level 9
That worked. Thanks!
RandoDando
Pyrite | Level 9

While the solution worked, upon closer inspection I see that the indentation for numeric columns (COL1 - COL4) is a lot wider than the indentation in the text column I have on the left side of the report for the same rows. For instance, if I request 1 space for the data on row 7, the text column (NAME) is in fact indented by 1 space, but the numeric values in the following columns for that row are indented further to the right.   How can I make the indentation match that of the first column?

 

compute COL4;	
if row in(7, 10, 11, 14, 31) then do;
         do i = 1 to 6; 
            call define (i, 'style', 'style=[pretext="A0"x]');  
         end;
		 end;

      if row in(8, 9, 15, 21, 22, 27, 33, 32) then do;
         do i = 1 to 6; 
            call define (i, 'style', 'style=[pretext="A0A0A0A0"x]'); 
         end;
end;

      if row in(16, 17, 18, 19, 20, 23, 24, 25, 26, 28, 29, 30) then do;
         do i = 1 to 6; 
            call define (i, 'style', 'style=[pretext="A0A0A0A0A0A0"x]'); 
end;
		 end; 

 

RAVI2000
Lapis Lazuli | Level 10
Did you find any solution?
Thanks in advance!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 6 replies
  • 4903 views
  • 0 likes
  • 3 in conversation