I do need to fix sas date formats here.
proc sql;
create table DATE as
select
case when i.dateofdeath =. then "31dec9999:00:00:0"dt
else i.dateofdeath end as ddate
from lib.ind as i
where region='x';
quit;
when I ran this query from SAS (lib is referenced for libname) I am getting ddate as 253717660800 for 31dec9999:00:00:0 and 1643587200 for 1/31/2012(in oracle dateofdeath column).
Q. I do need output ddate as in this format 01JAN2011:00:00:00?
Not sure if your dates are in SAS or oracle form, but you could try just adding a format statement. e.g.:
proc sql;
create table DATE as
select
case when i.dateofdeath =. then "31dec9999:00:00:0"dt
else i.dateofdeath end as ddate
format=datetime21.
from lib.ind as i
where region='x';
quit;
Not sure if your dates are in SAS or oracle form, but you could try just adding a format statement. e.g.:
proc sql;
create table DATE as
select
case when i.dateofdeath =. then "31dec9999:00:00:0"dt
else i.dateofdeath end as ddate
format=datetime21.
from lib.ind as i
where region='x';
quit;
my dates are in oracle form because I am running against oracl db
But they might still import in SAS form. I would try running the suggested code and check what you get.
Thank you art297 for your reply.
Is there any function like "nvl" in oracle pass through which works in proc sql?
coalesce
You can also consider using the datepart function if you're not interested in the time format (I rarely am, except when looking at ER info).
This might affect your running time, so keep that in mind.
proc sql;
create table DATE as
select
case when i.dateofdeath =. then "31dec9999"dt
else datepart(i.dateofdeath) end as ddate format date9.
from lib.ind as i
where region='x';
quit;
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.