BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
staplegunjelly
Fluorite | Level 6

Hello Everyone!

This is for a personal project of mine. I need to aggregate a ton of csv files to get my data prepped.

I have 2 datetime columns in my csv files which look like:

datetime_beginning_utc,datetime_beginning_ept
2/11/2022 5:00:00 AM,2/11/2022 12:00:00 AM

 

The date part of these values are in the mm/dd/yyyy format. When using proc import, the datetimes are being stored as:

staplegunjelly_0-1708541450074.png

Is there anyway to fix this? or any work arounds?

I'm using SAS 9.4

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@staplegunjelly wrote:

Hello Everyone!

This is for a personal project of mine. I need to aggregate a ton of csv files to get my data prepped.

I have 2 datetime columns in my csv files which look like:

datetime_beginning_utc,datetime_beginning_ept
2/11/2022 5:00:00 AM,2/11/2022 12:00:00 AM

 

The date part of these values are in the mm/dd/yyyy format. When using proc import, the datetimes are being stored as:

staplegunjelly_0-1708541450074.png

Is there anyway to fix this? or any work arounds?

I'm using SAS 9.4


What about that is wrong?

 

If you expected SAS to GUESS that by 2/11 you meant FEB 11th instead of 2nd of NOV then change the setting of the DATESTYLE system option from DMY to MDY before running PROC IMPORT.

 

Or better still write your own program to read the CSV file and you can have full control over how the text strings are read.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

@staplegunjelly wrote:

Hello Everyone!

This is for a personal project of mine. I need to aggregate a ton of csv files to get my data prepped.

I have 2 datetime columns in my csv files which look like:

datetime_beginning_utc,datetime_beginning_ept
2/11/2022 5:00:00 AM,2/11/2022 12:00:00 AM

 

The date part of these values are in the mm/dd/yyyy format. When using proc import, the datetimes are being stored as:

staplegunjelly_0-1708541450074.png

Is there anyway to fix this? or any work arounds?

I'm using SAS 9.4


What about that is wrong?

 

If you expected SAS to GUESS that by 2/11 you meant FEB 11th instead of 2nd of NOV then change the setting of the DATESTYLE system option from DMY to MDY before running PROC IMPORT.

 

Or better still write your own program to read the CSV file and you can have full control over how the text strings are read.

staplegunjelly
Fluorite | Level 6
I had no idea about the datastyle option. Thanks a lot! That did the job for me.
I also tried writing my own program but it worked differently across different csv files.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 527 views
  • 3 likes
  • 2 in conversation