• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: proc sql left join based on condition with missing values

Resolved: proc sql left join based on condition with missing values

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I am trying to combine two tables using left join for Reconciliation and there are two variables which I want to use for match condition. However, there is an additional requirement for one of the matched variable. If there is a match for second variable then pull that row from second table, if not then put the corresponding second value as missing and still extract other variables from the second table. But I am getting missing values if no match exist for second var. I know this is natural sql behavior. But I just want to try if anything can be done.
Here is a sample code:
Output I am getting
Output I have
Output I want
enter image description here
Appreciate your help!

Answer:

One thing you might consider is just INTERLEAVING the observations by ID and DATE and just using the latest value of OTHER_VAR on the dates from A.
So if you have this input data:
You can combine them like this:

If you have better answer, please add a comment about this, thank you!

sql
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How do I stop the command from happening if the requirements for it to work aren’t sert Discord.js

02/04/2023

Resolved: How to scroll bottom of div at launch?

02/04/2023

Resolved: how to get and read an xml file in a zip file using xml.etree

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.