BookmarkSubscribeRSS Feed
MZunnurain
Calcite | Level 5
I have an output time from %logparse macro which appears like this in
the csv file....


10:31:34.90 Representing 10 hours 31 minutes 34.90 seconds from the
log


When I open the csv file using Excel it appears like this...


31:34.9 without the 10 hours


when I click on the cell, a format showing as...


10:31:35 AM


Excel took its best guess, but this is not how I would like the time
to appear. I would like it to appear as 10:31:34.90 as in the csv
file. Any ideas? I can reformat myself using hh:mm:ss.000 but as
this will be used for multiple spreadsheets I would like it to be
automatic.
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
Hi:
When you use ODS CSV to create a report file that Excel can open, you are going to get all the Excel defaults. If you don't like the default format (column width, number format, etc) that Excel uses when it opens the CSV file -- you can use the pull-down menus -inside- Excel to change them.

There is a way to send a Microsoft format from ODS to Excel -- if you use
1) ODS HTML or ODS MSOFFICE2K destinations (HTML-based destinations), then you can use the HTMLSTYLE= style attribute to send an mso-number-format CSS style property to Excel (to use when it opens the HTML file);
2) ODS TAGSETS.EXCELXP destination (Spreadsheet markup language XML based destination) then you can use the TAGATTR= style attribute to send a Microsoft formula or format to Excel (to use when it opens the XML file).

There is a discussion and examples of both techniques in this paper:
http://www2.sas.com/proceedings/sugi28/012-28.pdf

cynthia
MZunnurain
Calcite | Level 5
Thank you Cynthia.

This worked from within ods html....


var realtime / style={htmlstyle="vnd.ms-excel.numberformat:hh:mm:ss.00"};
MZunnurain
Calcite | Level 5
Now if I could just get logparse to tell me data what? or sort what?
or sql what?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1300 views
  • 0 likes
  • 2 in conversation