/************************************/
/************************************/
/* */
/* SAS - Customer Success Latam */
/* */
/************************************/
/************************************/
/************************************/
/************************************/
/* */
/* Webinar: SAS y Excel */
/* 23Jun2022 */
/* */
/************************************/
/************************************/
/************************************/
/* Expositor: Daniel Vazquez Vargas */
/************************************/
/************************************/
/* Uso de "ODS tagsets.excelxp" */
/************************************/
/************************************/
/* Ejemplo de control del texto en */
/* Excel usando Proc Report */
/************************************/
/*-------------------*/
/* inicio del código */
/*-------------------*/
/* El ejemplo: */
/* Creamos 2 variables macro */
%let libreria=g:/temp/;
%let reporte=salida_bonita;
/* Creamos la tabla de datos que vamos a utilizar en el Proc Report */
data datos;
input Anio_fiscal $ pago_serv $ cantidad visitas;
datalines;
2019 1 4669 2669
2019 2 2045 3090
2019 3 814 2452
2019 4 364 1666
;
options nodate number orientation=landscape; /*configuración de página*/
ods tagsets.ExcelXP file = "&libreria./&reporte..xls" style=Gantt;
/* Antes de comenzar usamos muchas de las opciones de configuración */
/* que ofrece tagsets.ExcelXP */
ods tagsets.ExcelXP options(embedded_titles='yes' embedded_footnotes='yes'
background='white' orientation='landscape' FITTOPAGE = 'no'
row_repeat = '9-10' autofit_height = 'yes'
frozen_headers = 'yes' center_horizontal = 'yes'
skip_space='1,0,0,1,1'
doc='help'
merge_titles_footnotes='yes');
ods escapechar='^'; /*esta opción no la utilizamos en la versión definitiva*/
options missing = ''; /*esta opción tampoco la utilizamos en la versión definitiva*/
/* Configurando títulos y pies de páginas... */
ods tagsets.ExcelXP options(sheet_name="Esto es una prueba");
title1 justify=left font='Calibri' height=14pt color=white bold bcolor=darkblue
"Título 1 a izquierda blanco con fondo azul";
title2 justify=left font='Calibri' italic height=12pt
"Título 2 a izquierda en cursiva (itálica)";
footnote1 justify=center font='Calibri' height=10pt bold
"Pie de página 1 centrado y en negrita (bold)";
footnote2 justify=right font='Calibri' color=bip height=10pt
"Pie de página 2 a derecha color.. púrpura?";
/* Ahora sí comenzamos */
/* Creamos una tabla de ejemplo */
data datos;
set datos;
spantext="Año Fiscal 2019-2020";
run;
ods proclabel 'Esto es una prueba';
/* Vamos a usar Proc Report configurando formatos, colores, y mucho más */
proc report data=datos nowd split="*";
column Anio_fiscal spantext,(pago_serv cantidad Visitas);
define Anio_fiscal / 'Año calendario ' STYLE(column)={TAGATTR='format:text' width=1.5in};
define pago_serv / 'Trimestre ' style(column)={width=2in} style(header)={foreground=white background=green};
define cantidad / 'Cantidades ' format=commax10. style(column)={width=1.5in} style(header)={foreground=white background=green};
define Visitas / 'Visitas ' format=commax10. style(column)={width=1.5in} style(header)={foreground=white background=green};
define spantext / across ' ' style(header)={foreground=white background=green};
rbreak after / summarize style={foreground=#3245d1 background=#C0C0C0 font_weight=bold};
compute after;
Anio_fiscal = 'Total';
endcomp;
run;
ods tagsets.ExcelXP close;
title;
footnote;
ods listing;
/*--------------------*/
/* fin del código */
/*--------------------*/