BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
k_shide
Obsidian | Level 7

Dear SAS Gurus,

 

I have a CSV file contains like following.

 

12/19/2015 19:23:55 JST 

It looks like ordinary mm/dd/yyyy hh:mm:ss except it contains "JST" at the end which indicates Japan time zone like EST or CST in US. Without this time zone, it was OK with datetime19. but with this it does go into SAS dataset.

Do you have any good workaround to import this as datetime value to SAS?

Thank you Gurus,

Kaz

 

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

Hi

 

To read this from a CSV, I suggest to read the datetime value as char, and then use the INPUT function to convert the char value to a datetime value. See an example below.

 

data want;
  infile cards dlm=",";
  input
    id : 8.
    someDT_c : $32.
    text :$40.
  ;

  someDT = input(someDT_c, anydtdtm19.);
  format
    someDT datetime19.
  ;

/*  drop someDT_C;*/
cards;
123,12/19/2015 19:23:55 JST,somemore text
;

Bruno

View solution in original post

4 REPLIES 4
BrunoMueller
SAS Super FREQ

Hi

 

A SAS datetime value does not store any timezone information. Is the timezone information important for the processing?

 

Bruno

k_shide
Obsidian | Level 7

Thanks for your reply.

Time zone information not required. However, datetime19. does not import the first 19 digit and can't ignore the rest.

So if you know any good method to work around without any hussle, I appreciate it.

It's CSV file and I column pointer is a favourite method for use this case.

 

 

 

BrunoMueller
SAS Super FREQ

Hi

 

To read this from a CSV, I suggest to read the datetime value as char, and then use the INPUT function to convert the char value to a datetime value. See an example below.

 

data want;
  infile cards dlm=",";
  input
    id : 8.
    someDT_c : $32.
    text :$40.
  ;

  someDT = input(someDT_c, anydtdtm19.);
  format
    someDT datetime19.
  ;

/*  drop someDT_C;*/
cards;
123,12/19/2015 19:23:55 JST,somemore text
;

Bruno

k_shide
Obsidian | Level 7

Thanks very much. Probably that's the best way. 

dummy variable would be the best. I thought informats sometimes clever enough to take care of this kind of things but not this case.

 

Thank you,

Kaz

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 1878 views
  • 0 likes
  • 2 in conversation