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

Can this be done in the advanced expression calculation?

 

Example data to convert from char to SAS date:

 

02/12/2016 to 12FEB2016:00:00:00

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Will that tool let you type an actualy function?  If your variable with the characters in is named CHARVAR then this assignment statement will make the variable DATETIME have the equivalent datetime value.

datetime=dhms(input(charvar,'MMDDYY10.'),,,0);

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

Will that tool let you type an actualy function?  If your variable with the characters in is named CHARVAR then this assignment statement will make the variable DATETIME have the equivalent datetime value.

datetime=dhms(input(charvar,'MMDDYY10.'),,,0);
ChrisHemedinger
Community Manager

Yes, @Tom is correct.  The Advanced Expression window allows this:

 

dhms(input(t1.charvar,'MMDDYY10.'),,,0)

 

Looks like this in your window:

 

ae.png

 

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
Reeza
Super User

@ChrisHemedinger Are the quotes required around the format? I think it might be like the following:

 

dhms(input(t1.charvar, MMDDYY10.),,,0)

 

 

Tom
Super User Tom
Super User

With the INPUT() functions you do not want the quotes around the format since the second argument is a format.

But the INPUTN() function , or the INPUTC() function, take an expression for the second argument so you do need the quotes.

carmendee
Obsidian | Level 7

This worked.  I had to add DATETIME20 to the format under "Modify additional options" in Enterprise Guide.

 

Thanks all!

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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