Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Merge two columns of dates in the same data set

I would like to concatenate two columns of the same dataset:

    ID      Date1       Date2         
    001     1-1999            
    002                 2-2021
    003                 3-2021     
    004     03-2019                  
   ....     .......     ......

I tried:

data out1
  set out   
  Test = coalesce(Date1 Date2);
run;

but without success.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any suggestion?
Thank you in advance

>Solution :

My 2 suggestions:

  1. Make sure that you use the correct function. Coalesce for numeric values, coalesceC for character
  2. You are missing a comma between Date1 and Date2.

Do this

data have;
input ID $ (Date1 Date2)($);
infile datalines dlm = '|' missover;
datalines;  
001|1-1999 |       
002|       |2-2021 
003|       |3-2021 
004|03-2019|       
;

data want;
   set have;
   test = coalescec(Date1, Date2);
run;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading