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

I'm having trouble adding blank lines in proc report. I'd like to have a blank line everytime the Make changes for improved readability.  From googling I thought it's just the compute block part of my code below.

proc report data=sashelp.cars out=test_out(drop=_BREAK_);
	column Make Cylinders n;
	define Make / group;
	define Cylinders / group;
	define n / 'Count';
	compute after Make;
		line=' ';
	endcomp;
run;

Below is what the 1st few rows of what's in the report. I'd like blank rows where I indicated with < 

cluelesssas_0-1744995889901.png

And here is test_out. It seems extra rows are added (highlighted) but they are not blank. As a side note, note how row 2 repeats 'Acura' but above only has each Make 1x. This part is also confusing to me.

cluelesssas_1-1744996011222.png

Does any1 know how to actually get blank rows? Thx in advance for any help 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Use the LINE statement.  Your code it trying to make new variable named LINE.

proc report data=sashelp.cars;
	column Make Cylinders n;
	define Make / group;
	define Cylinders / group;
	define n / 'Count';
	compute after Make;
		line @1 ' ';
	endcomp;
run;

Tom_0-1744996335956.png

 

PS Why are you use the OUT= option on PROC REPORT?  If you want to make a dataset then why not just run a data step?

proc summary data=sashelp.cars nway;
  class Make Cylinders ;
  output out=test(drop=_type_ rename=(_freq_=Count));
run;

data test;
  set test;
  by make;
  output;
  if last.make then do;
    call missing(of _all_);
    output;
  end;
run;

proc print;
run;

Tom_0-1744996584867.png

 

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

Use the LINE statement.  Your code it trying to make new variable named LINE.

proc report data=sashelp.cars;
	column Make Cylinders n;
	define Make / group;
	define Cylinders / group;
	define n / 'Count';
	compute after Make;
		line @1 ' ';
	endcomp;
run;

Tom_0-1744996335956.png

 

PS Why are you use the OUT= option on PROC REPORT?  If you want to make a dataset then why not just run a data step?

proc summary data=sashelp.cars nway;
  class Make Cylinders ;
  output out=test(drop=_type_ rename=(_freq_=Count));
run;

data test;
  set test;
  by make;
  output;
  if last.make then do;
    call missing(of _all_);
    output;
  end;
run;

proc print;
run;

Tom_0-1744996584867.png

 

cluelesssas
Calcite | Level 5

 Thx Tom. I was dumb I didn't see there wasn't an = in the line statement.

As for why I tried to save output from proc report, it's because the deliverable I needed to make asked for the same summary tables to be put on multiple different sheets. Since the reports take some time to generate I didn't want to have SAS generate the exact same thing multiple times.

I think the way to go for me to save output is something like what you did in your 2nd code snippet.

 

proc report data=in_data out=out_summary;
*do a lot of stuff;
run;

proc report data=out_summary; *still not sure why this wont print the exact same thing!;
run;
Tom
Super User Tom
Super User

It does print the same thing because that is not what PROC REPORT is intended to do.  PROC REPORT is for printing reports.  Not sure what value is gotten out of saving the data it generated, but if you want that to reprint you probably need to use a different PROC REPORT step that the one you used to generate those statistics.

 

It will probably be much easier to just use normal SAS code to generate the statistics, like the PROC SUMMARY step I showed.  Then you can print it with PROC PRINT or perhaps with PROC REPORT if you want some formatting that PROC PRINT cannot do.

 

Of if you literally need the same output printed over and over then perhaps use PROC DOCUMENT to copy the ODS generate output multiple times?

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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
  • 426 views
  • 4 likes
  • 2 in conversation