Greetings,
I'm trying to manually create some rows in a table, with the insert to statement, coded looks like this:
proc sql;
insert into lib.table values(
'OPEN',
10001,
10041,
10004,
'13',
'ACT');
quit;
My question is, how do I insert a date such as (01JAN2017) so that it is a valid SAS date?
Thanks in advance.
for datetime use '01jan2017:00:00:00'dt
Try next code:
proc sql;
insert into lib.table values(
'OPEN',
10001,
10041,
10004,
'13',
'ACT',
'01jan2017'd
);
quit;
Thank you for your help, Shmuel, the answer you provided is correct.
However, it made me figure out that the column I'm trying to fill is actually datetime with a format of DATETIME22.3
I tried adjusting your solution to '01jan2017'dttm but it did not work.
for datetime use '01jan2017:00:00:00'dt
Please don't be a lazy programmer and name datetime values as dates. When crossing the boundary to SAS the values are quite different and functions/actions that will work on DATES will either fail or create very unexpected results when used with DATETIMES (and vice versa).
@Datino - if you decide to convert datetime to date use next code to do it:
date_var = datepart(datetime_var);
format date_var date9.;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.