Greetings
I have a table that has a datetime field and would like to update the field with today's date using the datetime format.
I have seen a way of updating a number field by doing this in the attached dataset:
Proc sql;
update test2
set hour = 50;
quit;
The code updates all values of the field "Hour"
I would like to update the field Date with today's date.
Furthermore, it might be required to update only a specific record say where name = 'John'. will there also be a way of updating specific record?
Thanks in advance
Proc sql;
update test2 set date = datetime();
alter table test2 modify date integer format=datetime16.;
quit;
Now test2 is a datetime value. NOTE: in some places you ask for a datetime value, and in other places you ask for a date value, which is it?
Proc sql;
update test2
set hour = datetime
where name = 'John';
quit;
Proc sql;
update test2 set date = datetime();
alter table test2 modify date integer format=datetime16.;
quit;
Now test2 is a datetime value. NOTE: in some places you ask for a datetime value, and in other places you ask for a date value, which is it?
Greetings
The solution worked perfectly. The customer request that I format today's date as a datetime field to a format 2022-02-21 13:56:45. This format starts with a year as it will suits his database field
The datetime in the accepted solution provides a datetime format that starts with the day and not the year.
Is there a way to update the field with this format?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.