I am not getting expected results in RTF when I use the following combination PROC RPORT, DEFINE xxx/ID, BREAK AFTER xx/PAGE.
Could you please help me? I have attached expected result and original from SAS.
Example code:
data tclass;
set sashelp.class;
name_=name; height_=height; age_=age; weight_=weight; sex_=sex;
pagenum=1;
run;
ods noresults;
ods listing close;
ods tagsets.rtf file='C:\temp.rtf';
proc report data=tclass nowd;
column pagenum name sex age height weight name_ sex_ age_ height_ weight_;
define pagenum/display order noprint;
define name/display style(column)={cellwidth=20%};
define sex/display style(column)={cellwidth=20%} id page;
define age/display;
define height/display;
define weight/display style(column)={cellwidth=20%};
define name_/display;
define sex_/display;
define age_/display;
define height_/display;
define weight_/display;
break after pagenum/page;
run;
ods tagsets.rtf close;
Hi:
When I run this example from my paper with Scott Huntley, http://support.sas.com/resources/papers/proceedings14/SAS038-2014.pdf. I get the same results in PDF, RTF and TAGSETS.RTF as shown in the paper. Generally, you put the PAGE option on a separate variable while the ID option identifies the variables that will repeat when the page needs to wrap, generally because the output is too wide. If you read the PROC REPORT documentation, it explains that, "for nonlisting destinations, the page break does not occur until all the rows in the report have been printed. Therefore, PROC REPORT prints all the rows for all the columns to the left of the PAGE column and then starts over at the top of the report and prints the PAGE column and the columns to the right." -- from the Base SAS(R) 9.4 Procedures Guide, Third Edition
I don't believe that your code is correctly using the PAGE option, based on the documentation. Since my sample code, using SASHELP.CARS does correctly "break" the page at the CYLINDER variable and then use MAKE and TYPE (the 2 ID items) on the next "page", I think you probably need to rework your real example.
Basically, it didn't make sense to me that you would want to put NAME and SEX and then have SEX be the ID variable -AND- the PAGE variable because the whole purpose of using ID and PAGE are to control when you have very wide reports that you KNOW will not fit on one page width and so you want to control which variable starts the "page". In my example, again, using SASHELP.CARS, when I use PAGE inappropriately, the documentation tip meaning becomes clear. The paging in #3 report is broken, PROC REPORT puts as many variables as it can to fit to the page width, ignores my PAGE specification (as explained in the doc) although the ID items are still used. For report #1 and #2 I get the expected results in all 3 destinations. My report #3 seems to be the closest to what you program is doing.
Cynthia
ods pdf file='c:\temp\ID_page.pdf';
ods rtf file='c:\temp\orig_ID_page.rtf';
ods tagsets.rtf file='C:\temp\tr_ID_page.rtf';
proc report data=sashelp.cars nowd spanrows
style(report)={width=100%};
title '1) PAGE specified separate from ID items';
where make = 'Mazda';
column Make Type Model Origin DriveTrain MSRP Invoice EngineSize
Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase Length;
define make / order id;
define type / order id;
define Cylinders / page;
break after make / page;
run;
ods _all_ close;
ods pdf file='c:\temp\ID_page_diff.pdf';
ods rtf file='c:\temp\orig_ID_page_diff.rtf';
ods tagsets.rtf file='C:\temp\tr_ID_page_diff.rtf';
proc report data=sashelp.cars nowd spanrows
style(report)={width=100%};
title '2) MSRP Different Place to put PAGE option';
where make = 'Mazda';
column Make Type Model Origin DriveTrain MSRP Invoice EngineSize
Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase Length;
define make / order id;
define type / order id;
define MSRP / page;
break after make / page;
run;
ods _all_ close;
ods pdf file='c:\temp\ID_page_diff3.pdf';
ods rtf file='c:\temp\orig_ID_page_diff3.rtf';
ods tagsets.rtf file='C:\temp\tr_ID_page_diff3.rtf';
proc report data=sashelp.cars nowd spanrows
style(report)={width=100%};
title '3) Putting the PAGE on MODEL "breaks" the paging, but ID still used';
where make = 'Mazda';
column Make Type Model Origin DriveTrain MSRP Invoice EngineSize
Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase Length;
define make / order id;
define type / order id;
define Model / page;
break after make / page;
run;
ods _all_ close;
Well, my suggestion would be to have two proc report statements, one to do the first part, then a second to do the second page.
ods tagsets.rtf file='C:\temp.rtf';
proc report data=tclass nowd;
column name sex age height weight name_ sex;
define name/display style(column)={cellwidth=20%};
define sex/display style(column)={cellwidth=20%} id page;
define age/display;
define height/display;
define weight/display style(column)={cellwidth=20%};
define name_/display;
define sex_/display;
run;
proc report data=tclass nowd;
column name age_ height_ weight_;
define name/display style(column)={cellwidth=20%};
define sex_/display;
define age_/display;
define height_/display;
define weight_/display;
run;
ods tagsets.rtf close;
Hi RW9, Thanks for you suggestion but it will not help me. I have given example code but I have data which has more than 1000 pages also have more number of variables. so I can not write code in this way. I do not want work around I want a solution.
Hi:
When I run this example from my paper with Scott Huntley, http://support.sas.com/resources/papers/proceedings14/SAS038-2014.pdf. I get the same results in PDF, RTF and TAGSETS.RTF as shown in the paper. Generally, you put the PAGE option on a separate variable while the ID option identifies the variables that will repeat when the page needs to wrap, generally because the output is too wide. If you read the PROC REPORT documentation, it explains that, "for nonlisting destinations, the page break does not occur until all the rows in the report have been printed. Therefore, PROC REPORT prints all the rows for all the columns to the left of the PAGE column and then starts over at the top of the report and prints the PAGE column and the columns to the right." -- from the Base SAS(R) 9.4 Procedures Guide, Third Edition
I don't believe that your code is correctly using the PAGE option, based on the documentation. Since my sample code, using SASHELP.CARS does correctly "break" the page at the CYLINDER variable and then use MAKE and TYPE (the 2 ID items) on the next "page", I think you probably need to rework your real example.
Basically, it didn't make sense to me that you would want to put NAME and SEX and then have SEX be the ID variable -AND- the PAGE variable because the whole purpose of using ID and PAGE are to control when you have very wide reports that you KNOW will not fit on one page width and so you want to control which variable starts the "page". In my example, again, using SASHELP.CARS, when I use PAGE inappropriately, the documentation tip meaning becomes clear. The paging in #3 report is broken, PROC REPORT puts as many variables as it can to fit to the page width, ignores my PAGE specification (as explained in the doc) although the ID items are still used. For report #1 and #2 I get the expected results in all 3 destinations. My report #3 seems to be the closest to what you program is doing.
Cynthia
ods pdf file='c:\temp\ID_page.pdf';
ods rtf file='c:\temp\orig_ID_page.rtf';
ods tagsets.rtf file='C:\temp\tr_ID_page.rtf';
proc report data=sashelp.cars nowd spanrows
style(report)={width=100%};
title '1) PAGE specified separate from ID items';
where make = 'Mazda';
column Make Type Model Origin DriveTrain MSRP Invoice EngineSize
Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase Length;
define make / order id;
define type / order id;
define Cylinders / page;
break after make / page;
run;
ods _all_ close;
ods pdf file='c:\temp\ID_page_diff.pdf';
ods rtf file='c:\temp\orig_ID_page_diff.rtf';
ods tagsets.rtf file='C:\temp\tr_ID_page_diff.rtf';
proc report data=sashelp.cars nowd spanrows
style(report)={width=100%};
title '2) MSRP Different Place to put PAGE option';
where make = 'Mazda';
column Make Type Model Origin DriveTrain MSRP Invoice EngineSize
Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase Length;
define make / order id;
define type / order id;
define MSRP / page;
break after make / page;
run;
ods _all_ close;
ods pdf file='c:\temp\ID_page_diff3.pdf';
ods rtf file='c:\temp\orig_ID_page_diff3.rtf';
ods tagsets.rtf file='C:\temp\tr_ID_page_diff3.rtf';
proc report data=sashelp.cars nowd spanrows
style(report)={width=100%};
title '3) Putting the PAGE on MODEL "breaks" the paging, but ID still used';
where make = 'Mazda';
column Make Type Model Origin DriveTrain MSRP Invoice EngineSize
Cylinders Horsepower MPG_City MPG_Highway Weight Wheelbase Length;
define make / order id;
define type / order id;
define Model / page;
break after make / page;
run;
ods _all_ close;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: