The easiest way is how @HunterT_SAS answered.
However, one way you could do something similar is by using ODS EXCEL and the REPORT procedure. The REPORT procedure summarizes data, or presents detailed data, based on your need. I'm not a proc report expert, but here is some code. I created a fake detailed data table, then summarized it using proc report, then exported it to Excel.
%let path = /*Enter your file path for the Excel file */;
%let fileName = myExcel.xlsx;
******************************************;
* create a fake sample detailed table *;
******************************************;
data testtable;
infile datalines delimiter=',';
input AnnoFiscale $ OrdineMese $ Jan Feb Mar Apr May Jun;
datalines;
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, Fatturato_progr, 100, 200, 300, 400, 500, 600
F22-23, qta_progr, 10, 20, 30, 40, 50, 60
F22-23, Fatturato_progr, 100, 200, 300, 400, 500, 600
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, Fatturato_progr, 100, 200, 300, 400, 500, 600
F22-23, qta_progr, 10, 20, 30, 40, 50, 60
F22-23, Fatturato_progr, 100, 200, 300, 400, 500, 600
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, Fatturato_progr, 100, 200, 300, 400, 500, 600
F22-23, qta_progr, 10, 20, 30, 40, 50, 60
F22-23, Fatturato_progr, 100, 200, 300, 400, 500, 600
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, qta_progr, 10, 20, 30, 40, 50, 60
F21-22, Fatturato_progr, 100, 200, 300, 400, 500, 600
F22-23, qta_progr, 10, 20, 30, 40, 50, 60
F22-23, Fatturato_progr, 100, 200, 300, 400, 500, 600
;
run;
*********************;
* Create Excel file *;
*********************;
* Set colors *;
%let backgroundColor = lightgray;
%let textColor = black;
ods excel file="&path.\&fileName"
options(sheet_interval='none') /*put all results on one sheet for testing*/;
proc report data=testtable spanrows
style(column)=[color=&textColor]
style(header)=[color=&textColor backgroundcolor=&backgroundColor];
* What columns you want *;
columns (AnnoFiscale OrdineMese Jan Feb Mar Apr May Jun);
* Specify what each column does in the report *;
define AnnoFiscale / group style=[backgroundcolor=&backgroundColor bordercolor=black];
define OrdineMese / group style=[backgroundcolor=&backgroundColor bordercolor=black];
run;
ods excel close;
Result
Resources:
PROC REPORT Doc
An Introduction to PROC REPORT
This is using something different, but might help if you can use it: The Armchair Quarterback: Writing SAS® Code for the Perfect Pivot (Table, That Is)
... View more