BookmarkSubscribeRSS Feed
BStenta
Calcite | Level 5

Hello,

 

In my raw data I am using seconds, and I need to format it into mmss. I used hms(0,0,<variable>) in my code, and then used format mmss. This worked properly in my SAS code/table; however, when I export the SAS table to a CSV file, some of the times are being formatted incorrectly (the large times). All of the data is correct in my SAS table, but for some reason when I open the CSV in excel, some of it is no longer accurate. 

 

Does anyone know why this might be occurring? I have attached a picture with two samples. 

 

Thanks, 

 

Bri 

 


SAS.jpg
3 REPLIES 3
ballardw
Super User

Your answer is here:

 

when I open the CSV in excel, some of it is no longer accurate

Excel makes assumptions about values when opening CSV and has been known to change things considerably. Loot at the value in the CSV using a Text program like Notepad or possibly Wordpad and you will see things basically the same as SAS.(unless you have SAVED the file with Excel. In which case re-export the values)

 

You can see what display format Excel has assigned to the cell an possibly select one that appears as needed.

BStenta
Calcite | Level 5

Thank you! You are right. When I open this file in Notepad, the formatting is correct.

 

Excel is using h:mm for the correct cells, and [h]:mm:ss for the incorrect cells. Is there a way to alter my SAS code so that this does not happen?? I need all the cells to be in the h:mm format. 

 

Thanks. 

ballardw
Super User

Proc export is going to give you much control.

If you have SAS 9.4 the EXCEL libname may help.

 

Or ODS tagsets.excelxp can create XML data that Excel can read. With proc print you can provide style appearance overrides and the TAGATTR option on specific variables to control how Excel interpret things.

I seldom get into that as I avoid Excel output as much as possible.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1055 views
  • 1 like
  • 2 in conversation