BookmarkSubscribeRSS Feed
GreggB
Pyrite | Level 9

my data is of the form:

2020/07/13 8:27:15 PM AST

 

I want to read it in as numeric so I can sort it. I want to format it to read as it is in the Google sheet.

I need help with

informat timestamp ?;

format timestamp  ? ;

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

1. Not using a 24h clock for time should be harshly punished

 

2. This reads your string:

 

proc format; 
  invalue weird_dtm 's/(\d*)\/([^ ]*)(.*)/$2\/$1$3/' (regexpe)=[anydtdtm32.];
data T;
  A = '2020/07/13 8:27:15 PM AST';
  B = input(a,weird_dtm.); 
  putlog B= datetime20.;
run;

B=13JUL2020:20:27:15

 

3. I am unsure what you want to do with the time zone. You might be interested in Overview of SAS Time Zones

 

 

GreggB
Pyrite | Level 9
The SAS System 


Obs A                       B 
1 2020/07/13 8:27:15 PM AST . 
Tom
Super User Tom
Super User

@GreggB wrote:

my data is of the form:

2020/07/13 8:27:15 PM AST

 

I want to read it in as numeric so I can sort it. I want to format it to read as it is in the Google sheet.

I need help with

informat timestamp ?;

format timestamp  ? ;


There a lot of unanswered questions for this.  What is the actual source of this data?  Sounds like you have SAS dataset with a character variable.  But then you mentioned Google sheet.  Do you have an XLSX compatible file?  Do you want to create an XLSX compatible file?

 

Do you care about the timezone or not?  That is do you just want to convert the value into a datetime value or do you want the result adjust so that values from different timezones can be compared?  So AST is 4 hours before GMT.  Note AST is the same offset from GMT as EDT (at least now).

 

What do you mean about formatting in the Google sheet?  Are you going to write a report and publish it as a Google worksheet?  Do you need the value stored in the Google sheet as datetime value with its offset from GMT?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 681 views
  • 2 likes
  • 4 in conversation