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

I would like to add blank rows of cells in this report. This is what I have so far using a dummy variable and compute block to insert them.

Have:

 

data Cars_report;
set sashelp.cars;
Total_Count = 1;
Blankrow = 1;
run;

ods excel file="\mydirectory\Cars_report.xlsx";
 PROC REPORT DATA = Cars_report   nowd;
 Title "Cars Report mean MSRP";
 COLUMN 
		Origin
		Total_Count
        DriveTrain
        MSRP,(Median Mean STD)
		Blankrow
        ;    
 DEFINE Origin        / group;
 DEFINE DriveTrain    / group;
 DEFINE Blankrow      / group ' ' noprint;

 BREAK AFTER Origin / summarize style=[background=graydd];
  COMPUTE AFTER Origin;
   DriveTrain="Any";
  ENDCOMP;

 RBREAK AFTER / summarize style=[background=lightblue];
  COMPUTE AFTER ;
   Origin="Any";
   DriveTrain="Any";
  ENDCOMP;

   compute after Blankrow;
     line ' ';
	 line ' ';
      endcomp;
   run; 
ods excel close;

DougHold_1-1674576806940.png

 

However, there should be 2 blank rows of cells (not one row that is two cells thick). Also, the blank rows should appear after the break summarize lines.

Want (with or without the inside cell borders, either of these would be fine):

DougHold_2-1674576965774.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:
PROC REPORT doesn't work like that. If you have 2 LINE statements in one COMPUTE block, then you get 2 lines in the same "cell" which is, as you indicated, 2 rows high. You'd need a separate compute block to get the line you envision.
Here's what I mean.

Cynthia_sas_0-1674581652133.png

  The highlighted sections show where I modified your code. Thanks, by the way, for posting code that was easily copied and pasted and used SASHELP data.

  When I am controlling breaks or inserting extra lines, I like to make my break variable (in your case, BLANKROW), the same as the first GROUP variable (in your case, ORIGIN) and I usually make it a character variable with some dummy string added at the end of the value. So when ORIGIN was Asia, my value for BLANKROW was Asia-9xx. This allowed me to put BLANKROW as the leftmost item on the COLUMN statement and ORIGIN as the next item. So then THAT allowed me to put one LINE statement inside the COMPUTE block for ORIGIN, which wrote the first empty line. The inner COMPUTE for ORIGIN would happen first. Then the OUTER COMPUTE for BLANKROW would happen next and write the second LINE statement.

  Notice that I changed the STYLEs on your COMPUTE blocks to control the style of the summary line separate from the style of the LINE statement. You can see this in "action" by not using NOPRINT and by putting a string inside the LINE statement:

Cynthia_sas_1-1674582191319.png

Cynthia

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:
PROC REPORT doesn't work like that. If you have 2 LINE statements in one COMPUTE block, then you get 2 lines in the same "cell" which is, as you indicated, 2 rows high. You'd need a separate compute block to get the line you envision.
Here's what I mean.

Cynthia_sas_0-1674581652133.png

  The highlighted sections show where I modified your code. Thanks, by the way, for posting code that was easily copied and pasted and used SASHELP data.

  When I am controlling breaks or inserting extra lines, I like to make my break variable (in your case, BLANKROW), the same as the first GROUP variable (in your case, ORIGIN) and I usually make it a character variable with some dummy string added at the end of the value. So when ORIGIN was Asia, my value for BLANKROW was Asia-9xx. This allowed me to put BLANKROW as the leftmost item on the COLUMN statement and ORIGIN as the next item. So then THAT allowed me to put one LINE statement inside the COMPUTE block for ORIGIN, which wrote the first empty line. The inner COMPUTE for ORIGIN would happen first. Then the OUTER COMPUTE for BLANKROW would happen next and write the second LINE statement.

  Notice that I changed the STYLEs on your COMPUTE blocks to control the style of the summary line separate from the style of the LINE statement. You can see this in "action" by not using NOPRINT and by putting a string inside the LINE statement:

Cynthia_sas_1-1674582191319.png

Cynthia

DougHold
Obsidian | Level 7

Thank you Cynthia, your explanations and tips are always so helpful.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 2 replies
  • 1098 views
  • 0 likes
  • 2 in conversation