Help using Base SAS procedures

SAS proc SQL / datastep merge problem

Reply
N/A
Posts: 0

SAS proc SQL / datastep merge problem

Hi all,

I have a proc SQL / datastep merge problem (I'm not sure which will lead to a more sophisticated solution). The problem is, that I have two 'big' enterprise level datasets the first having about 70 variables and the second having about 300 variables. The first data having more rows is done of the second dataset by splitting up industries to local kind of units. So, the first data has some of the variables from the second data, but not all and some additional variables.

What I need is to merge/join these two data's so that from the first data I will take all the variables and rows, and from the second data I have to add the rest of the variables to the new data (to the rows that have a largest value in some indicator, B here) and possibly also rows that are not in the first data. An example what I'm trying to do:

Data 1:
A B C
1 2 10
1 3 12
1 1 8
2 5 3
2 2 20

Data 2:
A C D E
1 30 3 5
2 23 2 7
3 14 5 7

Output data 3:

A B C D E
1 2 10
1 3 12 3 5
1 1 8
2 5 3 2 7
2 2 20
3 14 5 7

So, I need to keep the data from Data 1 and add the data from Data 2 if such rows do not exist in Data 1 (A=3) and add to the end of Data 1 the variables that do not exist in Data 1 (D and E) to the biggest B variable row having the same class (A).

Always I get the variable C from data 2 mixed to the variable C in data 1. Whether I'm using merge or SQL and in the solution I don't want to write all the variables in the SQL select row!

Best,
Antti
Ask a Question
Discussion stats
  • 0 replies
  • 102 views
  • 0 likes
  • 1 in conversation