Hi,
I am trying to generate a proc report from a huge sas dataset. I am having troubles while doing page break. I need to display (cont'd) as shown below in Example. I am able to create Output from Dataset 1. But I need to add Sub Cat 2 (cont'd) as shown below when page break occurs and report goes to 2nd page. How do I accomplish this ?
Below is just for example. I am working with a huge dataset which has 100s of Categories and Sub Categories. How do I write the code to create a page break and show (cont'd) in the next page along with the Sub Cat name at which the page break occured ?
Any help would be appreciated. Thanks much !
Could you use compute block ?
compute after _page_;
col='Continued ...... ';
endcomp;
Well, not much info given there, so bit of a guess. What I always do with my outputs is declare a page variable up front so I know exactly where the breaking will occur - you can do this as simply as saying X amount of observations = page 1, X amount= page 2 etc. or more complicated. But that is a different topic. Then in the proc report you break on that variable and page, then you can also use that to compute:
data want; set sashelp.class; if _n_ <= 10 then pge=1; else pge=2; run; ods rtf file...; proc report...; columns _all_; define pge / noprint; define...; break after pge / page; compute after pge; line 'Contd...'; endcomp; run; ods rtf close;
You need to tell the code. Have a look at the output, roughly how many do you want on one page? That then becomes your logic. You could create some algorithm to do it, and I have seen these floating around but they tens to be vast complicated things that only work half the time. You know your data and what you want your report to look like, so you need to fix it how you want.
I have the same problem: I need the "ordered" information after an automatic page break. In my example I need e.g. on page 2 (obs=27; and on followed pages) the information about 'origin' and 'make'. Further it would be nice to add "continued" - either as extra line before break or within the variables [e.g. in obs=27 "Asia (continued)" and "Hundai (continued)"] - but that is not necessary.
I have again and again long listings and that problem. I did not find a simple solution which I can add into my macros for different data sets / variables.
I could imagine that it could be possible - after e.g. every 26th OBS - that the variables 'origin' and 'make' can be written in new variables and only display these new variables (as 'display' and not 'order').
What do you all mean?
/** prepare DS for short example **/
DATA cars ;
SET sashelp.cars ;
IF origin not IN ("Asia","Europe","USA") THEN DELETE;
RUN ;
/** set options for example **/
OPTIONS papersize=A4 orientation=landscape ;
ods rtf file='myfile.rtf';
proc report nowd ps=40;
column obs origin make horsepower;
define obs / computed;
define origin / order;
define make / order;
define horsepower / display ;
compute obs; *used only to display problem;
dsobs + 1;
obs = dsobs;
endcompute;
run;
ods rtf close;
If data has 5 countries then how to get individual country on differnt page by using proc report
(Page 1 = India ) (Page 2 - China) (Page 3 - USA) (Page 4 - England) (Page 5 - Poland)
Just combine multiply PROC REPORT together .
ods rtf ....................;
proc report ......
where country='India';
..........
run;
proc report .......
where country='China';
...........
run;
Thank you for your reply.
I got the solution.
------------------------------------------------------------------------
data test1;
input first $ last $ num1 ;
cards;
first1 last1 1
first1 last2 2
first1 last3 3
first2 last4 4
first2 last5 5
first2 last6 6
first2 last7 7
first2 last8 8
first2 last9 9
first3 last1 2
;
run;
ods listing close;
ods pdf file='/temp/use_pgbrk1.pdf' notoc;
proc report data = test1 nowd ;
where first = "first1" ;
column first last num1;
define first/group ;
define last/display;
define num1/analysis;
run;
proc report data = test1 nowd ;
where first = "first2" ;
column first last num1;
define first/group ;
define last/display;
define num1/analysis;
run;
proc report data = test1 nowd ;
where first = "first3" ;
column first last num1;
define first/group ;
define last/display;
define num1/analysis;
run;
ods pdf close;
-----------------------------------------------------------------------------------------------------------------
But would need some automatic solution so that I can generate report e.g. 100 page and 100 record/headline of that each 100 records so how should I go with this data.
here I am not getting expected data , could you plz help me .
data final;
set test1;
order= _n_;
pgbrk=ceil(divide(order,4));
run ;
or share some other query for 100 individual records.
Regards,
Priyanka
I don't understand. You want each page have 100 rows ?
data temp;
set sashelp.cars(where=(type='SUV'));
if mod(_n_,10)=1 then page+1; /*<-- change 10 into 100*/
run;
proc report data=temp nowd;
column _all_;
define page/order;
break after page/page;
run;
Oh..
Ok .. I want a data from car.
data car ( keep = make type origin msrp ) ;
set sashelp.cars;
run;
Here, PFA for for clarification and I required each MAKE variable (Headline) of the report.
So,
1st page should have Acura on top of the report and other data (type origin msrp ) listing in table below.
2nd page should have Audi.................and its data
.
.
.
17th page Jeep.................and its data
...
38th Page volvo..................and its data
Thank you in advance
The simple way is using TITLE ?
data car ( keep = make type origin msrp ) ;
set sashelp.cars;
run;
options nodate nonumber;
title ' ';
ods pdf file='c:\temp\x.pdf';
title 'Manufactured by Acura';
proc report data=car nowd;
where make='Acura';
run;
title 'Manufactured by Audi';
proc report data=car nowd;
where make='Audi';
run;
ods pdf close;
Or use ODS TEXT=
[EDITED]
data car ( keep = make type origin msrp ) ;
set sashelp.cars;
run;
options nodate nonumber topmargin=1cm;
title ' ';
ods escapechar='~';
ods pdf file='c:\temp\x.pdf';
ods pdf startpage=now;
ods text='~S={just=center} Manufactured by Acura';
ods pdf startpage=no;
proc report data=car nowd;
where make='Acura';
run;
ods pdf startpage=now;
ods text='~S={just=center} Manufactured by Audi';
ods pdf startpage=no;
proc report data=car nowd;
where make='Audi';
run;
ods pdf 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 25. 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.