Need help to create tabular type report
see for rtf output;
https://www.dropbox.com/s/stvea5zojvzg7e6/prerpt.rtf?dl=0
I prefer to pre-process data before report and
minimize the use of compute blocks. Especially if
I feel management may ask for changes. You can get very close to the ops output with just my input and report without preprocessing, but that is a less flexible method?
inspired by
https://goo.gl/w4KKqr
https://communities.sas.com/t5/ODS-and-Base-Reporting/Need-help-to-create-tabular-type-report/m-p/342315
HAVE
====
Up to 40 obs WORK.HAVE total obs=7
Obs SALES DEPT AMOUNT CODE
1 Online Sale Clothing 1700 1612
2 Offline Sale Clothing 1300 .
3 Electronics1 Electronics . .
4 Electronics2 Electronics . .
5 Electronics3 Electronics . .
6 Stall1 Footware 2000 .
7 Stall2 Footware 1500 .
WANT
====
Total sales calculator February 2017 => Bold 12pt
Sales Overview Amount Center Code =Bold 10pt
Clothing Sales Total $3,000 1612 => Bold
Online Sale $1,700
Offline Sale $1,300
Electronics Sales Total => Bold
Electronics1
Electronics2
Electronics3
=> Bold
Footware Sales Total $3,500
Stall1 $2,000
Stall2 $1,500
=> Bold
Total $6,500
* create the data;
Using google 'free' tesseract to convert the ops pictute to data;
* print screen and save as a png and use google tesseract to convert to text;
x c:/progra~2/tesseract-ocr/tesseract d:/png/prepro.png d:/txt/prepro.txt;
* I useed Google te
Data have;
*informat Sales & $16. Amount & 5. code $5.;
length sales $32;
infile datalines4 pad;
input @1 dept $12. Sales & $16. @29 Amount & 5. @46 code ;
datalines4;
Clothing Online Sale 1700 1612
Clothing Offline Sale 1300 .
Electronics Electronics1 . .
Electronics Electronics2 . .
Electronics Electronics3 . .
Footware Stall1 2000 .
Footware Stall2 1500 .
;;;;
run;quit;
* preprocess;
data prerpt;
retain begdot 0 grantot 0 tot 0 cde 0;
do until (last.dept);
set have;
by dept notsorted;
tot=sum(tot,amount);
if code ne . then cde=code;
end;
code=cde;
amount=tot;
grantot=sum(grantot,tot);
sales=catx(' ','\b',dept,'Sales Total \b0');
output;
do until (last.dept);
set have end=dne;
by dept notsorted;
code=.;
sales=catx(' ','\li360',sales);
output;
end;
cde=.;
tot=0;
keep sales amount code;
if dne then do;
amount=grantot;
savsales=sales;
savamount=amount;
sales=.;
amount=.;
output;
sales='\b Total \b0';
savsales=savsales;
amount=savamount;
output;
end;
run;quit;
/*
Up to 40 obs WORK.PRERPT total obs=12
Obs SALES AMOUNT CODE
1 \b Clothing Sales Total \b0 3000 1612
2 \li360 Online Sale 1700 .
3 \li360 Offline Sale 1300 .
4 \b Electronics Sales Total \b0 0 .
5 \li360 Electronics1 . .
6 \li360 Electronics2 . .
7 \li360 Electronics3 . .
8 \b Footware Sales Total \b0 3500 .
9 \li360 Stall1 2000 .
10 \li360 Stall2 1500 .
11 . . .
12 \b Total \b0 6500 .
*/
* macro on end;
%utl_rtflan100;
options orientation=portrait;
ods escapechar='^';
ods rtf file="d:/rtf/prerpt.rtf" style=utl_rtflan100;
proc report data=prerpt nowd style(header)={font_weight=bold font_size=10pt just=left};
cols ("^S={just=l font_weight=bold font_size=12pt} Total sales calculator February 2017" sales amount code);
define sales / display "Sales Overview" left;
define amount / display "Amount" center format=dollar8.;
define code / display "Center Code" center;
run;quit;
ods rtf close;
%Macro utl_rtflan100
(
style=utl_rtflan100,
frame=box,
rules=groups,
bottommargin=1.0in,
topmargin=1.5in,
rightmargin=1.0in,
cellheight=10pt,
cellpadding = 7,
cellspacing = 3,
leftmargin=.75in,
borderwidth = 1
) / Des="SAS Rtf Template for CompuCraft";
options orientation=landscape;run;quit;
ods path work.templat(update) sasuser.templat(update) sashelp.tmplmst(read);
Proc Template;
define style &Style;
parent=styles.rtf;
replace body from Document /
protectspecialchars=off
asis=on
bottommargin=&bottommargin
topmargin =&topmargin
rightmargin =&rightmargin
leftmargin =&leftmargin
;
replace color_list /
'link' = blue
'bgH' = _undef_
'fg' = black
'bg' = _undef_;
replace fonts /
'TitleFont2' = ("Arial, Helvetica, Helv",11pt,Bold)
'TitleFont' = ("Arial, Helvetica, Helv",11pt,Bold)
'HeadingFont' = ("Arial, Helvetica, Helv",10pt)
'HeadingEmphasisFont' = ("Arial, Helvetica, Helv",10pt,Italic)
'StrongFont' = ("Arial, Helvetica, Helv",10pt,Bold)
'EmphasisFont' = ("Arial, Helvetica, Helv",10pt,Italic)
'FixedFont' = ("Courier New, Courier",9pt)
'FixedEmphasisFont' = ("Courier New, Courier",9pt,Italic)
'FixedStrongFont' = ("Courier New, Courier",9pt,Bold)
'FixedHeadingFont' = ("Courier New, Courier",9pt,Bold)
'BatchFixedFont' = ("Courier New, Courier",7pt)
'docFont' = ("Arial, Helvetica, Helv",10pt)
'FootFont' = ("Arial, Helvetica, Helv", 9pt)
'StrongFootFont' = ("Arial, Helvetica, Helv",8pt,Bold)
'EmphasisFootFont' = ("Arial, Helvetica, Helv",8pt,Italic)
'FixedFootFont' = ("Courier New, Courier",8pt)
'FixedEmphasisFootFont'= ("Courier New, Courier",8pt,Italic)
'FixedStrongFootFont' = ("Courier New, Courier",7pt,Bold);
replace GraphFonts /
'GraphDataFont' = ("Arial, Helvetica, Helv",8pt)
'GraphAnnoFont' = ("Arial, Helvetica, Helv",8pt)
'GraphValueFont' = ("Arial, Helvetica, Helv",10pt)
'GraphUnicodeFont' = ("Arial, Helvetica, Helv",10pt)
'GraphLabelFont' = ("Arial, Helvetica, Helv",10pt,Bold)
'GraphLabel2Font' = ("Arial, Helvetica, Helv",10pt,Bold)
'GraphFootnoteFont' = ("Arial, Helvetica, Helv",8pt)
'GraphTitle1Font' = ("Arial, Helvetica, Helv",11pt,Bold)
'GraphTitleFont' = ("Arial, Helvetica, Helv",11pt,Bold);
style table from table /
outputwidth=100%
protectspecialchars=off
asis=on
background = colors('tablebg')
frame=&frame
rules=&rules
cellheight = &cellheight
cellpadding = &cellpadding
cellspacing = &cellspacing
bordercolor = colors('tableborder')
borderwidth = &borderwidth;
replace Footer from HeadersAndFooters
/ font = fonts('FootFont') just=left asis=on protectspecialchars=off ;
replace FooterFixed from Footer
/ font = fonts('FixedFootFont') just=left asis=on protectspecialchars=off;
replace FooterEmpty from Footer
/ font = fonts('FootFont') just=left asis=on protectspecialchars=off;
replace FooterEmphasis from Footer
/ font = fonts('EmphasisFootFont') just=left asis=on protectspecialchars=off;
replace FooterEmphasisFixed from FooterEmphasis
/ font = fonts('FixedEmphasisFootFont') just=left asis=on protectspecialchars=off;
replace FooterStrong from Footer
/ font = fonts('StrongFootFont') just=left asis=on protectspecialchars=off;
replace FooterStrongFixed from FooterStrong
/ font = fonts('FixedStrongFootFont') just=left asis=on protectspecialchars=off;
replace RowFooter from Footer
/ font = fonts('FootFont') asis=on protectspecialchars=off just=left;
replace RowFooterFixed from RowFooter
/ font = fonts('FixedFootFont') just=left asis=on protectspecialchars=off;
replace RowFooterEmpty from RowFooter
/ font = fonts('FootFont') just=left asis=on protectspecialchars=off;
replace RowFooterEmphasis from RowFooter
/ font = fonts('EmphasisFootFont') just=left asis=on protectspecialchars=off;
replace RowFooterEmphasisFixed from RowFooterEmphasis
/ font = fonts('FixedEmphasisFootFont') just=left asis=on protectspecialchars=off;
replace RowFooterStrong from RowFooter
/ font = fonts('StrongFootFont') just=left asis=on protectspecialchars=off;
replace RowFooterStrongFixed from RowFooterStrong
/ font = fonts('FixedStrongFootFont') just=left asis=on protectspecialchars=off;
replace SystemFooter from TitlesAndFooters / asis=on
protectspecialchars=off just=left;
end;
run;
quit;
%Mend utl_rtflan100;
... View more