DATA Step, Macro, Functions and more

Replace data from one dataset to another conditionally

Reply
Occasional Contributor
Posts: 5

Replace data from one dataset to another conditionally

I have two dataset A and B

dataset A:
year Quarter Amount
2012 Q4 200
2013  Q4 300
2014  Q4 400
2015 Q4  500
2016 Q4 600

dataset B:
year quarter Amount
2013 Q4 400
2014 Q4 510.45
2015 Q4 600
2016 Q4  700

i want to replace the amount values which have been changed in dataset B in Dataset A.
Could you please let me know how to do it in SAS.

My output should be
Dataset A:
year Quarter Amount
2012 Q4 200
2013  Q4 400
2014  Q4 510.45
2015 Q4  600
2016 Q4 700

Super User
Posts: 5,256

Re: Replace data from one dataset to another conditionally

Take the free Programming 1 course where you will learning techniques like this.

Data never sleeps
Occasional Contributor
Posts: 5

Re: Replace data from one dataset to another conditionally

Okay sure. But I need to do this urgently. Could you please help me do this in SAS
Super User
Posts: 5,256

Re: Replace data from one dataset to another conditionally

This is not a training site. Simple inquiries that can be read directly from documentation or teached in introductory classes in not in my priority list.

The responders here volunteer.

I don't care if it's urgent or not, who decides which is most important among the thousands of questions that are posted here?

I'm here for the fun of it, and help people with basic tasks because they lack of planning is not it.

Data never sleeps
Super User
Posts: 6,936

Re: Replace data from one dataset to another conditionally

Make sure that both datasets are sorted by year and quarter.

Do a data step update, as described here: https://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001329153.htm

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 4 replies
  • 110 views
  • 0 likes
  • 3 in conversation