Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!

re: Proc Report Break After

Accepted Solution Solved
Reply
Regular Contributor
Posts: 248
Accepted Solution

re: Proc Report Break After

 

Hi....I am trying to break and summarize only when Order1 =1. Order1 has the numeric values of 1 and 2. Is it possible to specify or select specific values where the breaks and summarization will occur. Right now it is breaking after Order1 = 1 and Order1 = 2.

 

Thanks.

 

ODS PDF FILE="%sysfunc(pathname(project))\Enrollment and Graduate Report (&rundate).PDF" STYLE=MINIMAL NOTOC BOOKMARKGEN=NO BOOKMARKLIST=NONE STARTPAGE=NOW;
PROC REPORT DATA=AcadYearUniqStudentFinal MISSING ps=43 ls=108 NOWD spanrows
		style(report)={frame=box just=CENTER WIDTH=60%};

COLUMN ('Unique Number Students Enrolled1'n 'Unique Number Students Enrolled'n 'Unique Number Students Admitted'n Order1);
DEFINE 'Academic Year'n / GROUP 'Academic Year *' ;
DEFINE 'Unique Number Students Enrolled1'n / ANALYSIS 'Enrolled (Final)**' ;
DEFINE 'Unique Number Students Enrolled'n / ANALYSIS 'Enrolled (Initial)***' ;
DEFINE 'Unique Number Students Admitted'n / ANALYSIS 'Admitted****' ;  
DEFINE Order1 / ORDER NOPRINT; 

break after Order1 / skip summarize;
	compute after Order1;
			Module = 'Total **';
	if Module  ^= ' '
		then call define (_row_, "style", "style={background=lawngreen}");
	 endcomp;

run;
quit;

Accepted Solutions
Solution
‎03-13-2018 09:08 AM
SAS Super FREQ
Posts: 9,434

Re: re: Proc Report Break After

Hi:
  You didn't post any data, so any comments that people will make on your posted code will mean that they are only guessing.

  Order1 is an ORDER variable. You said that Order1 has possible values of 1 and 2. and you only want summation to happen after the values for 1 and not for the values of 2. This is not how PROC REPORT performs break processing.

  I do have some comments on your code, however. LS and PS are ignored for ODS destinations, like ODS PDF.  SKIP will also be ignored by ODS PDF. What are you doing with the Module item? Is it a temporary variable? I do not see it in your COLUMN statement.

Also, you have a DEFINE Statement for Academic Year, but I don't see it in a COLUMN statement, so I would expect you to get an error like this:
WARNING: 'Academic Year'n is not in the report definition.

  However, making some fake data, that may or may not be in the structure that your data are in, I produced this code. Note that my data has slightly different variable names and colors from your code because it was my data and so I used simpler names and the fluorescent green made my eyes hurt. I took NOPRINT off ORDER1, so it was clear where the BREAK line was occuring and I added the LINE statement to mimic the SKIP option.

Here's the output:

academic_year.png

And here's my code:

data fakedata;
  infile datalines;
  input Order1 uniq_enrl1 uniq_enrol uniq_admit acad_year;
return;
datalines; 
1 777 1436 1179 2016 
1 922 1124 1261 2016 
2 767 1691 1259 2016 
2 842 2176 1264 2016 
1 734 1428 1356 2017 
1 848 1666 1275 2017 
1 816 1322 1162 2017 
2 897 1912 1469 2017 
2 811 1742 1442 2017
2 825 1531 1343 2017 
run;
 
ODS PDF FILE="c:\temp\fakedata.PDF" STYLE=MINIMAL 
    NOTOC BOOKMARKGEN=NO BOOKMARKLIST=NONE;
PROC REPORT DATA=fakedata MISSING NOWD spanrows
		style(report)={frame=box just=CENTER WIDTH=60%};
column acad_year uniq_enrl1 uniq_enrol uniq_admit   Order1;
DEFINE acad_year / GROUP 'Academic Year *' ;
DEFINE uniq_enrl1 / ANALYSIS 'Enrolled (Final)**' ;
DEFINE uniq_enrol / ANALYSIS 'Enrolled (Initial)***' ;
DEFINE uniq_admit / ANALYSIS 'Admitted****' ;  
DEFINE Order1 / ORDER ; 

break after Order1 /  summarize;
compute after Order1;
  line ' ';
  call define (_row_, "style", "style={background=lightgreen}");
endcomp;
run;
 
ods pdf close;



As you can see, by default, PROC REPORT wants to produce a break line for every unique value of ORDER 1.

cynthia

View solution in original post


All Replies
Solution
‎03-13-2018 09:08 AM
SAS Super FREQ
Posts: 9,434

Re: re: Proc Report Break After

Hi:
  You didn't post any data, so any comments that people will make on your posted code will mean that they are only guessing.

  Order1 is an ORDER variable. You said that Order1 has possible values of 1 and 2. and you only want summation to happen after the values for 1 and not for the values of 2. This is not how PROC REPORT performs break processing.

  I do have some comments on your code, however. LS and PS are ignored for ODS destinations, like ODS PDF.  SKIP will also be ignored by ODS PDF. What are you doing with the Module item? Is it a temporary variable? I do not see it in your COLUMN statement.

Also, you have a DEFINE Statement for Academic Year, but I don't see it in a COLUMN statement, so I would expect you to get an error like this:
WARNING: 'Academic Year'n is not in the report definition.

  However, making some fake data, that may or may not be in the structure that your data are in, I produced this code. Note that my data has slightly different variable names and colors from your code because it was my data and so I used simpler names and the fluorescent green made my eyes hurt. I took NOPRINT off ORDER1, so it was clear where the BREAK line was occuring and I added the LINE statement to mimic the SKIP option.

Here's the output:

academic_year.png

And here's my code:

data fakedata;
  infile datalines;
  input Order1 uniq_enrl1 uniq_enrol uniq_admit acad_year;
return;
datalines; 
1 777 1436 1179 2016 
1 922 1124 1261 2016 
2 767 1691 1259 2016 
2 842 2176 1264 2016 
1 734 1428 1356 2017 
1 848 1666 1275 2017 
1 816 1322 1162 2017 
2 897 1912 1469 2017 
2 811 1742 1442 2017
2 825 1531 1343 2017 
run;
 
ODS PDF FILE="c:\temp\fakedata.PDF" STYLE=MINIMAL 
    NOTOC BOOKMARKGEN=NO BOOKMARKLIST=NONE;
PROC REPORT DATA=fakedata MISSING NOWD spanrows
		style(report)={frame=box just=CENTER WIDTH=60%};
column acad_year uniq_enrl1 uniq_enrol uniq_admit   Order1;
DEFINE acad_year / GROUP 'Academic Year *' ;
DEFINE uniq_enrl1 / ANALYSIS 'Enrolled (Final)**' ;
DEFINE uniq_enrol / ANALYSIS 'Enrolled (Initial)***' ;
DEFINE uniq_admit / ANALYSIS 'Admitted****' ;  
DEFINE Order1 / ORDER ; 

break after Order1 /  summarize;
compute after Order1;
  line ' ';
  call define (_row_, "style", "style={background=lightgreen}");
endcomp;
run;
 
ods pdf close;



As you can see, by default, PROC REPORT wants to produce a break line for every unique value of ORDER 1.

cynthia

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 185 views
  • 0 likes
  • 2 in conversation