To display a date or time in Excel using the ExcelXP tagset you need to have a column that is formated with the E8601DT. format. This will allow you to use the TAGATTR otion to specify how you want to display a date or time in Excel. The sample below shows different data types and how to format them (or some default formatting). data have;
attrib
someText format=$32.
someDate format=ddmmyyp10.
someDateXLS format=E8601DT.
someTime format=time8.
someTimeXLS format=E8601DT.
someNumber format=comma12.2
someCurrency format=dollar14.2
somePct format=nlpct8.2
;
do i = 1 to 20;
someText = catx("_", i, put(i, roman.));
someDate = today() - 100 + i;
someDateXLS = dhms(someDate, 0, 0, 0);
someTime = time() - i;
someTimeXLS = dhms(someDate, 0, 0, someTime);
someNumber = (ranuni(i) * 5000) + 1000;
someCurrency = (ranuni(i*123) * 10000) + 1000;
somePct = ranuni(0);
output;
end;
drop i;
run;
ods tagsets.ExcelXP file="c:/temp/value_format.xml"
style=analysis
options(
embedded_titles='yes'
embedded_footnotes='yes'
)
;
title "SAS -> Excelxp";
proc report data=have;
define someDateXLS /
/* style(column) = {tagattr='TYPE:DateTime format:[$-F800]DDDD, MMMM DD, YYYY'}*/
style(column) = {tagattr='TYPE:DateTime format:dd.mm.yyyy'}
;
define sometimeXLS /
style(column) = {tagattr="TYPE:DateTime format:hh:mm:ss;@"}
;
define someNumber /
style(column) = {tagattr="Format:#,##0"}
;
run;
title;
ods tagsets.ExcelXP close; I just noticed, that the code formatting "eats up" part of the text, see the screenshot below:
... View more