My code is as follows:
proc sql;
create table dataset_new as
SELECT m.*, case when date_1 is not null thendate_1 else date_2 end as new_date
from dataset_old m
left join joined_table c on m.id_prior =c.id
where 1=1;
quit;
However, when I go to the new_date column, the values are displayed as integers and not as dates. Please advise on how to proceed.
SAS dates are integers, counting the days from 1960-01-01. Apply a date format (like YYMMDD10.) to make them human-readable.
And why do you use that complicated CASE, when a simple COALESCE function would do it?
coalesce(date_1,date_2) format=yymmdd10. as new_date
now the output is just asterisk signs
then you likely have a datetime, ie a time component is one each date.
Try the DTDATE9. format or tell us what the format is on your original variables.
@aalluru wrote:
now the output is just asterisk signs
Show us such a value without the format.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.