Macro and SAS code:
/*---------------------------------------------------------------------
! ESRMGL46 : Macro to CREATE directly formatted EXCEL
! :
! Author : CST - Albert Jacobs (AJA) / Jos Van der Plancken (JVDP)
! Parm :
!---------------------------------------------------------------------
! Date !Vs! Opdracht / Contract ! Name
!--------!--!-------------------------------------------------!-------
! !00! Start development / in production ! AJA/JVDP
! !00! !
! !00! ( see ECAR 1283166 ) !
! !00! macro ESRMGL46: added this info Header, ! DDE
! ! ! ( =in accordance with STANDARD PROCEDUREs !
!28/04/09!00! Prepared for ValueSource ! DDE
'---------------------------------------------------------------------*/
%macro esrmgl46(size=10);
libname t1047 'esrpt000.dsns.t1047.templat.test' disp=shr;
ods path t1047.templat(read) sashelp.tmplmst(read);
ods tagsets.tableeditor file=_webout rs=none
style=t1047.mystyle
options(excel_zoom="90"
excel_scale="90"
excel_frozen_headers="yes"
sheet_name="Table"
excel_table_move="1"
file_format="ext"
nowrap="yes"
fontfamily="arial"
header_size="&size"
rowheader_size="&size"
data_size="&size"
title_size="15"
);
%put &sysver;
%mend;
%macro esrm5702;
/*---------------------------------------------------------------.
! esdm5702: Detail cijfers-Alle modellen !
! Auteur: CST - Jan Van Lint !
! Rapitweb : KPI4 Verhouding stock-repair per week !
! Alle modellen !
!----------------------------------------------------------------!
! Datum !Vs! Opdracht ! Naam !
!--------!--!-------------------------------------------!--------!
!04/07/07!00! begin ontwikkeling ! Jan !
.----------------------------------------------------------------*/
libname geg 'ESCPT000.DSNS.ASSET.WEEK.test' disp=shr;
data wkpi4; set geg.assets;
where status ='Operational' or (status='Repair'
and (stock='KBC MAG - HP' or stock =: 'KBC MAG - DROPPOINT'));
if stock =: 'KBC MAG - DROPPOINT' then do;
stock = 'KBC MAG - DROPPOINT'; end;
run;
proc sort data=wkpi4;
by model status;
run;
data kpi4 (keep=model statuscode rep oper perc);
set wkpi4;
by model status;
if first.model then do;
rep=0;
oper=0;
end;
If status= 'Repair' then rep+1;
else oper+1;
If last.model then do;
if oper = 0 then Perc=100;
else Perc=round((rep*100)/oper,.01);
output kpi4;
end;
run;
proc sort data=kpi4 ;
by model;
run;
/* Sorteren van de gebruikerstabel per model */
proc sort data=geg.models out=tabm (drop=kpi5 group5);
by model;
run;
/* Merge van de bestanden*/
data kpi4m;
merge kpi4 (in=in1) Tabm (in=in2);
by model;
if in1 and in2;
run;
proc sort data=kpi4m;
by kpi4 model;
run;
data _null_;
call symput('fjaar',compress(year(today())));
run;
data _NULL_;
date=date();
weekt=int(( date+(6-(mod(date,7))-7*((mod(date,7))<3))-
mdy(1,1,year(date+(6-(mod(date,7))-7*((mod(date,7))<3)))))/7);
call symput('weekt',compress(weekt));
run;
options nodate pageno=1 symbolgen mprint missing = '';
%esrmgl46;
title 'Assets in repair in proportion to operational assets';
title2 h=50 'All models';
title3 "For week &weekt of &fjaar";
proc report data=kpi4m box nowd ls=120;
column KPI4 model statuscode rep oper perc;
define kpi4 / order 'Type' width=10;
define model / order width=40;
define statuscode / order width=40;
define rep / display 'Repair' width=7;
define oper / display 'Operat.' width=8;
define Perc / display 'Perc' format=6.2;
compute perc;
if (oper < 100 and perc > 5) or(oper >100 and perc>2) then
call define (_col_,"style","style={background=red}");
endcomp;
run;
ods tagsets.tableeditor close;
%mend esrm5702;
... View more