BookmarkSubscribeRSS Feed
aalluru
Obsidian | Level 7

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.

4 REPLIES 4
Kurt_Bremser
Super User

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
aalluru
Obsidian | Level 7

now the output is just asterisk signs

Reeza
Super User

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


 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 990 views
  • 0 likes
  • 3 in conversation