DATA Step, Macro, Functions and more

Merging variables

Accepted Solution Solved
Reply
Regular Contributor
Posts: 182
Accepted Solution

Merging variables

Hi!  I merged two data sets by Patient ID, but realized two variables (PatDOB, PatDOB1) were named differently but both serve as birthddate.  So, now half values are under PATDOB1 and others under PATDOB.  They are both formatted same (mmddyy10.), so is there a way to move all values in PATDOB1 to PATDOB and then delete the variable PATDOB1?

 

Thanks!!


Accepted Solutions
Solution
‎11-20-2015 01:09 PM
Esteemed Advisor
Posts: 5,528

Re: Merging variables

PATDOB = coalesce(PATDOB, PATDOB1);

 

coalesce returns the first argument that is not missing.

PG

View solution in original post


All Replies
Regular Contributor
Posts: 161

Re: Merging variables

If you don't have a risk of over-writing one date with another, then just use an assignment statement and drop the unwanted variable, the simplest I can think of.... 

Kannan Deivasigamani
Solution
‎11-20-2015 01:09 PM
Esteemed Advisor
Posts: 5,528

Re: Merging variables

PATDOB = coalesce(PATDOB, PATDOB1);

 

coalesce returns the first argument that is not missing.

PG
Regular Contributor
Posts: 182

Re: Merging variables

@PGStats Thank you!

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 219 views
  • 1 like
  • 3 in conversation