BookmarkSubscribeRSS Feed
deleted_user
Not applicable
This is the timevar as it currently reads: 2009-03-24T09:00 it is considered character format $200.

by a simple recoding I can get: 200903240900 Best12. format

I would like to have this in timedate format or be able to split it into the time and date seperately.

(the dataset was imported from a seperate comapny I did not create it)

Any help or insight would be wonderful! 🙂
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi,
To convert a character string to a numeric variable you would use an assignment statement, something like:
[pre]
numvar = input(charvar,informat_name.);
[/pre]

if your character string is in a date or date time form, then you would need to look up the correct INformat in the documentation. BEST12 would NOT be the correct INformat to use.

Cynthia
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Recommended Google advanced search argument for this topic/post:

sas datetime values site:sas.com

Also, there are SAS functions DATEPART and TIMEPART, if you want to split a DATETIME variable. And, as Cynthia mentioned, it's key to apply the proper SAS format as you desire the output to be displayed, since SAS DATE and DATETIME variables are numeric internally, as can be picked-up from the DOC references.

Scott Barry
SBBWorks, Inc.
Peter_C
Rhodochrosite | Level 12
there are informats like IS8601xx (in SAS9) which I think are designed to handle these types of date and time data formats.
There is also ANYDTDTM informat which would search for a suitable datetime informat. It gave me these results (SAS9.1.3 sp4)
436 %put %sysfunc( inputn( %str(2009-03-24T09:00), anydtdtm), datetime );
.
437 %put %sysfunc( inputn( %str(2009-03-24T09:00:00), anydtdtm), datetime );
24MAR09:09:00:00

This shows that the informat ANYDTDTM expects the seconds to be provided.
So does IS8601DT.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 763 views
  • 0 likes
  • 4 in conversation