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.
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.
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.
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.
@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.
@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.
@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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.