I have the data that need to be output in Excel format, I am having difficulty how I can create a spanning extra cell like shown in the image. Thank you
data have;
input student age math1 math2 sci1 sci2;
cards;
01 10 36 34 54 45
02 12 34 43 45 56
03 12 34 43 45 56
04 16 34 43 15 46
05 15 34 47 75 56
06 12 34 43 35 76
07 15 33 43 25 66
08 14 34 43 55 56
09 12 38 41 45 54
;
run;
ods listing close;
ods ESCAPECHAR = '^';
ods excel file="\desktop\est1.xlsx"
options(sheet_name='LIFE Version'
autofilter='all' ) style= SeasidePrinter ;
/*BASELINE VERSION -LIFETIME*/
PROC REPORT data=have nowindows
style(report)=[font=("Times New Roman", 10pt) protectspecialchars=on]
style(header)=[font=("Times New Roman", 10pt, bold) backgroundcolor= yellow just=center protectspecialchars=on]
style(column)=[font=("Times New Roman", 10pt) protectspecialchars=on];
*where cond2='Y';
COLUMN student age math1 math2 sci1 sci2;
DEFINE student / "student" display style=[just=c vjust=t cellwidth=2.882cm /*tagattr='type:num format:Text'*/];
DEFINE age /"Age" display style=[just=c vjust=t cellwidth=1.5cm /*tagattr='type:num format:Text'*/];
DEFINE math1 / "Maths 1" display style=[just=c vjust=t cellwidth=1.882cm tagattr='type:num '];
DEFINE math2 /"Maths 2" display style=[just=c vjust=t cellwidth=2.5cm /*tagattr='type:num format:Text'*/];
DEFINE sci1 /"Science 1" display style=[just=c vjust=t cellwidth= 2 cm /*tagattr='type:num format:Text'*/];
DEFINE sci2 /"Science 2" display style=[just=c vjust=t cellwidth= 2 cm /*tagattr='type:num format:Text'*/];
run;
ods excel close;
ods listing close;
How I have
How I want
This gets you closer:
COLUMN student age ('Maths Total' math1 math2) ('Science Total' sci1 sci2);
This gets you closer:
COLUMN student age ('Maths Total' math1 math2) ('Science Total' sci1 sci2);
It worked, Thanks
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.