BookmarkSubscribeRSS Feed
lmyers2
Obsidian | Level 7

Hello

 

I have 2 date variables formatted as datetime20 and am trying to find the number of days between the two dates. Below is sample data and code that doesn't work. I keep getting an error saying "There was a problem with the format so BEST. was used."

 

Patient     HET     DISCH_DHMS

1

2

3

 

data finalbicopd; set finalbicopd;

los=intck('day', datepart(HET), datepart(DISCH_DHMS), 'C');

run;

 

 

4 REPLIES 4
ballardw
Super User

If the values are actually datetimes, both of them then the interval to use is 'dtday', which tells SAS both values are datetimes and that you want the day intervals.

 

Anytime you get an 'error' or other message you do not understand copy the data step or procedure code along with ALL the messages generated by the step or proc, open a text box on the forum with the </> icon and paste all of the text.

 

Since you do not show anything explicitly using formats anywhere I suspect you may have issue with one of your variables. You may need to run proc contents on the source data set and check.

However since you used the code

data finalbicopd; set finalbicopd;

you have completely replace the Finalbicopd data set and the attributes may not be as they were.

 

I suspect you are getting a WARNING, not an error. There is indeed a difference. in SAS. Errors would keep the data step from running.

 

lmyers2
Obsidian | Level 7

Thanks - attached is the error message I get even after I submit other statements to sas (proc univariate, etc). It won't stop listing this as an error until I quit the "submitted statements."

 

 
 

 

 

Tom
Super User Tom
Super User

Please don't post photographs of text. And if you do have to post photographs do it by clicking on the camera icon in the editor bar instead of inserting the photograph into the a word file and attaching the word file to your posting.

 

Please show the type, length (and any formats if any are attached) for your source variables.

 

Kurt_Bremser
Super User

Quote from @Tom 's post:

open a text box on the forum with the </> icon

It is this button that you HAVE to use when posting logs:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

The "little running man" right next to it is for posting SAS code. ALWAYS use this button to post code. Do NOT post pictures of code or logs, always copy/paste the text. It makes helping ypu easier and will get you quicker answers.

 

Since your original code has no format reference in it, your problem has to come from the input dataset. Most likely there is a custom format attached to one or more variables, but the FMTSEARCH option is not properly set (or the format is not defined in your environment at all), so SAS can't find it.

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!

5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 451 views
  • 0 likes
  • 4 in conversation