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;
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):
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.
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
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.
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
Thank you Cynthia, your explanations and tips are always so helpful.
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.
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.
Ready to level-up your skills? Choose your own adventure.