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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.