BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Satish_Parida
Lapis Lazuli | Level 10

I have a dataset where I have a variable which is in date9 format.

 

I am changing the date to datetime using fomat as following.

 

data proclib.a_e_1;
format AEENDTC DATETIME20. AEENRF $12. AESEV $64. AESR $12. AESTDTC DATETIME20. AETERM $124. COUNTRY $12. SITEID 
$16. STUDYID $36. SUBJID 8.;
set proclib.a_e;
run;

In this Process the dates are getting appended with current time stamp from the system or some random time stamp.
I need them to be 00:00:00.

 

Is there any way of controlling that.

 

Thanks in Advance.

1 ACCEPTED SOLUTION

Accepted Solutions
6 REPLIES 6
Kurt_Bremser
Super User

SAS dates are counts of days, SAS datetimes are counts of seconds.

datetime = dhms(date,0,0,0);

will convert a date to a datetime. Or multiply by 86400.

Satish_Parida
Lapis Lazuli | Level 10

The Problem is the column assignment is dynamic and I do not know the column names the time I write the code.

 

The formats are derived from a source table, which is in oracle so the difference of data and datetime (Oracle always sends dates as datetime)

 

So I can not use dhms in the code as I wont be knowing the variable names.

 

Thank you for quick response. 

PaigeMiller
Diamond | Level 26

@Satish_Parida wrote:

The Problem is the column assignment is dynamic and I do not know the column names the time I write the code.

 


But this is an entirely different problem than the one you described originally.

 

It may be that some sort of logic and use of macros will help you solve this. But you'd have to describe the problem in a lot more detail.

--
Paige Miller
ballardw
Super User

@Satish_Parida wrote:

The Problem is the column assignment is dynamic and I do not know the column names the time I write the code.

 

The formats are derived from a source table, which is in oracle so the difference of data and datetime (Oracle always sends dates as datetime)

 

So I can not use dhms in the code as I wont be knowing the variable names.

 

Thank you for quick response. 


Since Oracle always sends the value as date time where are you getting a date from that needs to be converted back to datetime? This kind of sounds like a somewhat flawed process. I would go back to where you convert the Oracle datetime value to a date and re-examine what you are doing to the data.

Kurt_Bremser
Super User

@Satish_Parida wrote:

The Problem is the column assignment is dynamic and I do not know the column names the time I write the code.

 

The formats are derived from a source table, which is in oracle so the difference of data and datetime (Oracle always sends dates as datetime)

 

So I can not use dhms in the code as I wont be knowing the variable names.

 

Thank you for quick response. 


You can't write code without knowing the data. So you either have fixed names, or names supplied by another means (macro variables, call execute off datasets). Your argument is therefore a non-argument.

Satish_Parida
Lapis Lazuli | Level 10

Yes, you are correct. I was trying to find out an easy way out rather than writing very complex macro functions to achieve this.

 

Thank you.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 46185 views
  • 2 likes
  • 4 in conversation