Hello,
Can you please help me to create a line at the bottom of each page in the report? If you look at the output that is generated you will see that the line on the first page is fine because it's at the bottom of the page, however the line on the second page is not at the bottom of the page, the line starts directly when the report finishes. I'm also using RTF output because I need to select the data in each column after the output has been produced. This seems to work fine when I use proc printto, but I can't get it to work when I use ods RTF file. Thank you in advance for your help!
The code I used is below:
data exprev;
input Country $ 1-24 Emp_ID $ 25-32 Order_Date $ Ship_Date $ Sale_Type $ 67-75 Quantity Price Cost;
datalines;
Antarctica 99999999 1/1/12 1/7/12 Internet 2 92.60 20.70
Puerto Rico 99999999 1/1/12 1/5/12 Catalog 14 51.20 12.10
Virgin Islands (U.S.) 99999999 1/1/12 1/4/12 In Store 25 31.10 15.65
Aruba 99999999 1/1/12 1/4/12 Catalog 30 123.70 59.00
Bahamas 99999999 1/1/12 1/4/12 Catalog 8 113.40 28.45
Bermuda 99999999 1/1/12 1/4/12 Catalog 7 41.00 9.25
Belize 120458 1/2/12 1/2/12 In Store 2 146.40 36.70
British Virgin Islands 99999999 1/2/12 1/5/12 Catalog 11 40.20 20.20
Canada 99999999 1/2/12 1/5/12 Catalog 100 11.80 5.00
Cayman Islands 120454 1/2/12 1/2/12 In Store 20 71.00 32.30
Costa Rica 99999999 1/2/12 1/6/12 Internet 31 53.00 26.60
Cuba 121044 1/2/12 1/2/12 Internet 12 42.40 19.35
Dominican Republic 121040 1/2/12 1/2/12 Internet 13 48.00 23.95
El Salvador 99999999 1/2/12 1/6/12 Catalog 21 266.40 66.70
Guatemala 120931 1/2/12 1/2/12 In Store 13 144.40 65.70
Haiti 121059 1/2/12 1/2/12 Internet 5 47.90 23.45
Honduras 120455 1/2/12 1/2/12 Internet 20 66.40 30.25
Jamaica 99999999 1/2/12 1/4/12 In Store 23 169.80 38.70
Mexico 120127 1/2/12 1/2/12 In Store 30 211.80 33.65
Montserrat 120127 1/2/12 1/2/12 In Store 19 184.20 36.90
Nicaragua 120932 1/2/12 1/2/12 Internet 16 122.00 28.75
Panama 99999999 1/2/12 1/6/12 Internet 20 88.20 38.40
Saint Kitts/Nevis 99999999 1/2/12 1/6/12 Internet 20 41.40 18.00
St. Helena 120360 1/2/12 1/2/12 Internet 19 94.70 47.45
St. Pierre/Miquelon 120842 1/2/12 1/16/12 Internet 16 103.80 47.25
Turks/Caicos Islands 120372 1/2/12 1/2/12 Internet 10 57.70 28.95
United States 120372 1/2/12 1/2/12 Internet 20 88.20 38.40
Anguilla 99999999 1/2/12 1/6/12 In Store 15 233.50 22.25
Antigua/Barbuda 120458 1/2/12 1/2/12 In Store 31 99.60 45.35
Argentina 99999999 1/2/12 1/6/12 In Store 42 408.80 87.15
Barbados 99999999 1/2/12 1/6/12 In Store 26 94.80 42.60
Bolivia 120127 1/2/12 1/2/12 In Store 26 66.00 16.60
Brazil 120127 1/2/12 1/2/12 Catalog 12 73.40 18.45
Chile 120447 1/2/12 1/2/12 In Store 20 19.10 8.75
Colombia 121059 1/2/12 1/2/12 Internet 28 361.40 90.45
Dominica 121043 1/2/12 1/2/12 Internet 35 121.30 57.80
Ecuador 121042 1/2/12 1/2/12 In Store 11 100.90 50.55
Falkland Islands 120932 1/2/12 1/2/12 In Store 15 61.40 30.80
French Guiana 120935 1/2/12 1/2/12 Catalog 15 96.40 43.85
Grenada 120931 1/2/12 1/2/12 Catalog 19 56.30 25.05
Guadeloupe 120445 1/2/12 1/2/12 Internet 21 231.60 48.70
Guyana 120455 1/2/12 1/2/12 In Store 25 132.80 30.25
Martinique 120841 1/2/12 1/3/12 In Store 16 56.30 31.05
Netherlands Antilles 99999999 1/2/12 1/6/12 In Store 31 41.80 19.45
Paraguay 120603 1/2/12 1/2/12 Catalog 17 117.60 58.90
Peru 120845 1/2/12 1/2/12 Catalog 12 93.80 41.75
St. Lucia 120845 1/2/12 1/2/12 Internet 19 64.30 28.65
Suriname 120538 1/3/12 1/3/12 Internet 22 110.80 29.35
;
run;
proc sort data = exprev;
by country;
run;
data exprev2;
set exprev end = eof;
lastrec = eof;
if _n_ <= 32 then pageb = 1;
else pageb = 2;
run;
proc template;
define style Styles.rtf_kriss;
parent = styles.rtf;
style body from body /
marginleft = 34.5mm
marginright = 34.0mm
margintop = 18.2mm
marginbottom = 14.2mm;
style fonts from fonts ;
class table /
frame = void
rules = none
backgroundcolor = white
borderspacing = 0pt
cellpadding = 0pt;
style allrulestable from table /
frame = void
rules = none;
class color_list /
'bg' = white
'fg' = black
'bgH' = white
'link' = black;
end;
run;
ods rtf file = "help.rtf" style=styles.rtf_kriss ;
proc report data=exprev2 nowd spacing = 2;
column lastrec Country Sale_Type Quantity pageb;
define lastrec / display noprint;
define pageb / order noprint;
define country /width=24 center;
define Sale_Type / width=9 center;
define Quantity / width=8 center;
break after pageb / page;
compute after _page_ / left;
if not lastrec then
contline = "(CONTINUED)";
else
contline = "___________";
line @1 "%sysfunc(repeat(%str(_),%eval(119-12)))" contline $11.;
endcomp;
run;
ods rtf close;
How about :
data exprev;
input Country & $40. (Emp_ID Order_Date Ship_Date Sale_Type Quantity Price Cost) (& $20.);
datalines;
Antarctica 99999999 1/1/12 1/7/12 Internet 2 92.60 20.70
Puerto Rico 99999999 1/1/12 1/5/12 Catalog 14 51.20 12.10
Virgin Islands (U.S.) 99999999 1/1/12 1/4/12 In Store 25 31.10 15.65
Aruba 99999999 1/1/12 1/4/12 Catalog 30 123.70 59.00
Bahamas 99999999 1/1/12 1/4/12 Catalog 8 113.40 28.45
Bermuda 99999999 1/1/12 1/4/12 Catalog 7 41.00 9.25
Belize 120458 1/2/12 1/2/12 In Store 2 146.40 36.70
British Virgin Islands 99999999 1/2/12 1/5/12 Catalog 11 40.20 20.20
Canada 99999999 1/2/12 1/5/12 Catalog 100 11.80 5.00
Cayman Islands 120454 1/2/12 1/2/12 In Store 20 71.00 32.30
Costa Rica 99999999 1/2/12 1/6/12 Internet 31 53.00 26.60
Cuba 121044 1/2/12 1/2/12 Internet 12 42.40 19.35
Dominican Republic 121040 1/2/12 1/2/12 Internet 13 48.00 23.95
El Salvador 99999999 1/2/12 1/6/12 Catalog 21 266.40 66.70
Guatemala 120931 1/2/12 1/2/12 In Store 13 144.40 65.70
Haiti 121059 1/2/12 1/2/12 Internet 5 47.90 23.45
Honduras 120455 1/2/12 1/2/12 Internet 20 66.40 30.25
Jamaica 99999999 1/2/12 1/4/12 In Store 23 169.80 38.70
Mexico 120127 1/2/12 1/2/12 In Store 30 211.80 33.65
Montserrat 120127 1/2/12 1/2/12 In Store 19 184.20 36.90
Nicaragua 120932 1/2/12 1/2/12 Internet 16 122.00 28.75
Panama 99999999 1/2/12 1/6/12 Internet 20 88.20 38.40
Saint Kitts/Nevis 99999999 1/2/12 1/6/12 Internet 20 41.40 18.00
St. Helena 120360 1/2/12 1/2/12 Internet 19 94.70 47.45
St. Pierre/Miquelon 120842 1/2/12 1/16/12 Internet 16 103.80 47.25
Turks/Caicos Islands 120372 1/2/12 1/2/12 Internet 10 57.70 28.95
United States 120372 1/2/12 1/2/12 Internet 20 88.20 38.40
Anguilla 99999999 1/2/12 1/6/12 In Store 15 233.50 22.25
Antigua/Barbuda 120458 1/2/12 1/2/12 In Store 31 99.60 45.35
Argentina 99999999 1/2/12 1/6/12 In Store 42 408.80 87.15
Barbados 99999999 1/2/12 1/6/12 In Store 26 94.80 42.60
Bolivia 120127 1/2/12 1/2/12 In Store 26 66.00 16.60
Brazil 120127 1/2/12 1/2/12 Catalog 12 73.40 18.45
Chile 120447 1/2/12 1/2/12 In Store 20 19.10 8.75
Colombia 121059 1/2/12 1/2/12 Internet 28 361.40 90.45
Dominica 121043 1/2/12 1/2/12 Internet 35 121.30 57.80
Ecuador 121042 1/2/12 1/2/12 In Store 11 100.90 50.55
Falkland Islands 120932 1/2/12 1/2/12 In Store 15 61.40 30.80
French Guiana 120935 1/2/12 1/2/12 Catalog 15 96.40 43.85
Grenada 120931 1/2/12 1/2/12 Catalog 19 56.30 25.05
Guadeloupe 120445 1/2/12 1/2/12 Internet 21 231.60 48.70
Guyana 120455 1/2/12 1/2/12 In Store 25 132.80 30.25
Martinique 120841 1/2/12 1/3/12 In Store 16 56.30 31.05
Netherlands Antilles 99999999 1/2/12 1/6/12 In Store 31 41.80 19.45
Paraguay 120603 1/2/12 1/2/12 Catalog 17 117.60 58.90
Peru 120845 1/2/12 1/2/12 Catalog 12 93.80 41.75
St. Lucia 120845 1/2/12 1/2/12 Internet 19 64.30 28.65
Suriname 120538 1/3/12 1/3/12 Internet 22 110.80 29.35
;
run;
proc sort data = exprev;
by country;
run;
data exprev2;
set exprev end = eof;
lastrec = eof;
if _n_ <= 32 then pageb = 1;
else pageb = 2;
run;
ods rtf file = "/folders/myfolders/x.rtf" style=sasweb;
footnote " (CONTINUED) ";
proc report data=exprev2 nowd ;
where pageb =1;
column Country Sale_Type Quantity ;
define country / center ;
define Sale_Type / center ;
define Quantity / center ;
run;
footnote " %sysfunc(repeat(_,100)) ";
proc report data=exprev2 nowd ;
where pageb =2;
column Country Sale_Type Quantity ;
define country / center ;
define Sale_Type / center ;
define Quantity / center ;
run;
ods rtf close;
ods rtf file='/folders/myfolders/x.rtf' bodytitle style=sasweb;
footnote " %sysfunc(repeat(_,100)) ";
proc print data=sashelp.class;run;
ods rtf close;
Thank you Xia. Do you know how I can get this to work on outputs that are more than one page please, and also have the footer consistently on the bottom of the page?
Thank you.
How about :
data exprev;
input Country & $40. (Emp_ID Order_Date Ship_Date Sale_Type Quantity Price Cost) (& $20.);
datalines;
Antarctica 99999999 1/1/12 1/7/12 Internet 2 92.60 20.70
Puerto Rico 99999999 1/1/12 1/5/12 Catalog 14 51.20 12.10
Virgin Islands (U.S.) 99999999 1/1/12 1/4/12 In Store 25 31.10 15.65
Aruba 99999999 1/1/12 1/4/12 Catalog 30 123.70 59.00
Bahamas 99999999 1/1/12 1/4/12 Catalog 8 113.40 28.45
Bermuda 99999999 1/1/12 1/4/12 Catalog 7 41.00 9.25
Belize 120458 1/2/12 1/2/12 In Store 2 146.40 36.70
British Virgin Islands 99999999 1/2/12 1/5/12 Catalog 11 40.20 20.20
Canada 99999999 1/2/12 1/5/12 Catalog 100 11.80 5.00
Cayman Islands 120454 1/2/12 1/2/12 In Store 20 71.00 32.30
Costa Rica 99999999 1/2/12 1/6/12 Internet 31 53.00 26.60
Cuba 121044 1/2/12 1/2/12 Internet 12 42.40 19.35
Dominican Republic 121040 1/2/12 1/2/12 Internet 13 48.00 23.95
El Salvador 99999999 1/2/12 1/6/12 Catalog 21 266.40 66.70
Guatemala 120931 1/2/12 1/2/12 In Store 13 144.40 65.70
Haiti 121059 1/2/12 1/2/12 Internet 5 47.90 23.45
Honduras 120455 1/2/12 1/2/12 Internet 20 66.40 30.25
Jamaica 99999999 1/2/12 1/4/12 In Store 23 169.80 38.70
Mexico 120127 1/2/12 1/2/12 In Store 30 211.80 33.65
Montserrat 120127 1/2/12 1/2/12 In Store 19 184.20 36.90
Nicaragua 120932 1/2/12 1/2/12 Internet 16 122.00 28.75
Panama 99999999 1/2/12 1/6/12 Internet 20 88.20 38.40
Saint Kitts/Nevis 99999999 1/2/12 1/6/12 Internet 20 41.40 18.00
St. Helena 120360 1/2/12 1/2/12 Internet 19 94.70 47.45
St. Pierre/Miquelon 120842 1/2/12 1/16/12 Internet 16 103.80 47.25
Turks/Caicos Islands 120372 1/2/12 1/2/12 Internet 10 57.70 28.95
United States 120372 1/2/12 1/2/12 Internet 20 88.20 38.40
Anguilla 99999999 1/2/12 1/6/12 In Store 15 233.50 22.25
Antigua/Barbuda 120458 1/2/12 1/2/12 In Store 31 99.60 45.35
Argentina 99999999 1/2/12 1/6/12 In Store 42 408.80 87.15
Barbados 99999999 1/2/12 1/6/12 In Store 26 94.80 42.60
Bolivia 120127 1/2/12 1/2/12 In Store 26 66.00 16.60
Brazil 120127 1/2/12 1/2/12 Catalog 12 73.40 18.45
Chile 120447 1/2/12 1/2/12 In Store 20 19.10 8.75
Colombia 121059 1/2/12 1/2/12 Internet 28 361.40 90.45
Dominica 121043 1/2/12 1/2/12 Internet 35 121.30 57.80
Ecuador 121042 1/2/12 1/2/12 In Store 11 100.90 50.55
Falkland Islands 120932 1/2/12 1/2/12 In Store 15 61.40 30.80
French Guiana 120935 1/2/12 1/2/12 Catalog 15 96.40 43.85
Grenada 120931 1/2/12 1/2/12 Catalog 19 56.30 25.05
Guadeloupe 120445 1/2/12 1/2/12 Internet 21 231.60 48.70
Guyana 120455 1/2/12 1/2/12 In Store 25 132.80 30.25
Martinique 120841 1/2/12 1/3/12 In Store 16 56.30 31.05
Netherlands Antilles 99999999 1/2/12 1/6/12 In Store 31 41.80 19.45
Paraguay 120603 1/2/12 1/2/12 Catalog 17 117.60 58.90
Peru 120845 1/2/12 1/2/12 Catalog 12 93.80 41.75
St. Lucia 120845 1/2/12 1/2/12 Internet 19 64.30 28.65
Suriname 120538 1/3/12 1/3/12 Internet 22 110.80 29.35
;
run;
proc sort data = exprev;
by country;
run;
data exprev2;
set exprev end = eof;
lastrec = eof;
if _n_ <= 32 then pageb = 1;
else pageb = 2;
run;
ods rtf file = "/folders/myfolders/x.rtf" style=sasweb;
footnote " (CONTINUED) ";
proc report data=exprev2 nowd ;
where pageb =1;
column Country Sale_Type Quantity ;
define country / center ;
define Sale_Type / center ;
define Quantity / center ;
run;
footnote " %sysfunc(repeat(_,100)) ";
proc report data=exprev2 nowd ;
where pageb =2;
column Country Sale_Type Quantity ;
define country / center ;
define Sale_Type / center ;
define Quantity / center ;
run;
ods rtf close;
Thank you for this code Xia, this really helps! I also used some of the RTF control words so that a border (overline) was produced over the first footnote.
Such as
footnote1 "*R'\brdrt\brdrs\brdrw15\ql\li500\fi-500\par '"||trim(fnotes1);
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.