Desktop productivity for business analysts and programmers

Merge/Combine 2 columns into 1 to replace blank cells

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Merge/Combine 2 columns into 1 to replace blank cells

As part of a large data set, 2 of my columns contain dates that basically represent the same thing, and they both have missing data in different rows.

 

For example:

Column A      Column B     Date_Start   Date_Begin    Column E

                                              1/1/15          1/1/15

                                              1/4/15

                                                                  1/6/15

                                              1/7/15

                                              1/9/15          1/9/15

 

How do I combine the Date_Start and Date_Begin columns to replace the blank cells so that I get something like this:

 

Date_Combine

       1/1/15

       1/4/15

       1/6/15

       1/7/15

       1/9/15

 

I've also tried Proc Sql, Proc Format, and simply copying Date_Begin across to Data_Start (seen at the end) but it doesn't seem to be working i.e. If Missing(Date_Start) then Date_Start = Date_Begin

 

Any help with the coding would be appreciated!


Accepted Solutions
Solution
‎07-12-2017 09:01 PM
PROC Star
Posts: 283

Re: Merge/Combine 2 columns into 1 to replace blank cells

coalesce function will do it.

 

proc sql;

select coalesce(Date_Start ,  Date_Begin) as Date_Combine

from yourtable;

quit;

View solution in original post


All Replies
Solution
‎07-12-2017 09:01 PM
PROC Star
Posts: 283

Re: Merge/Combine 2 columns into 1 to replace blank cells

coalesce function will do it.

 

proc sql;

select coalesce(Date_Start ,  Date_Begin) as Date_Combine

from yourtable;

quit;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 165 views
  • 1 like
  • 2 in conversation