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

Hello all!

Pretty lost here, im working on creating a dataset using proc sql with DATETIME() field being the start_date, and trying to make end_date using intnx function using the query below,

 

intnx('day', date time(), -1) as end_date format=datetime20.

DATETIME() field is already in DATETIME20. format, but the results show '.' for end_date when it finishes running.

Any idea what could be happening? The proc sql is built using a prebuilt proc sql table and one data table. 

 

Thank you for the help!

IMG_0877-3-min.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

I think you want this:

 

intnx('dtday', datetime(), -1) as end_date format=datetime20.

 

'DAY' works only on SAS date variables. 'DTDAY' works on SAS date/time variables. The DATETIME() function produces a date/time variable.

 

Please note in your original code, you have a space between date and time, that will never work.

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

I think you want this:

 

intnx('dtday', datetime(), -1) as end_date format=datetime20.

 

'DAY' works only on SAS date variables. 'DTDAY' works on SAS date/time variables. The DATETIME() function produces a date/time variable.

 

Please note in your original code, you have a space between date and time, that will never work.

--
Paige Miller
darklord
Obsidian | Level 7
Hello,
Thank you for the help! I suppose should have searched harder online, didn't come across this DTDAY function.
The output looks good now 🙂
PaigeMiller
Diamond | Level 26

So technically, DTDAY is an argument to the INTNX function

All possible intervals that you can use here: http://documentation.sas.com/doc/en/pgmmvacdc/9.4/leforinforref/n0pxq4af0hx60nn1i1x3xn41mc3c.htm#n0z...

--
Paige Miller
darklord
Obsidian | Level 7
Appreciate the link:)

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!

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
  • 1805 views
  • 0 likes
  • 2 in conversation