I have two sets of SAS tables in the attached Excel file. I want to integrate observations from table 1 to table 2 one-to-one. What existed SAS statement able to do it?
Message was edited by: Dow Chang
Thank you, Reeza
Yes, MERGE and By statements can do one-to-one merging as the SAS Learning Module shown.
That is Match-Merging.
But, my problem is the Non-Match-Merging.
I would like to see the merging result of two tables in the attached Excel file, if you have it.
You may need an algorithm in programming.
Or you have better ideas?
Please correct me if I am wrong.
Dow
Hi ... the two tables have the same variable names and different numbers of observations (881 and 896). When you say integrate one-to-one, just what do you mean?
Please, see my reply to Reeza.
Thanks, MikeZdeb
Dow
You've provided the input, but you need to provide an example of what the output would look like.
You can also merge without specifying a by statement, If you just want the two tables side by side, merge without a by but then you'll need to rename all the columns in one of the tables because they have the same names.
ie
data class;
merge sashelp.class sashelp.class( keep=name age sex rename = (name=name2 age=age2 sex=sex2));
run;
Reeza,
I provide you with only a part of the output. You can find them in the two tables.
As the example shown, the purpose of this merge is to link observations one-to-one for a piece of information; Obs, in table 2 only.
State | County | Month | Day | Sex | Age | State_D | County_D | Month_D | Day_D | Sex_D | Age_D | Obs |
---|---|---|---|---|---|---|---|---|---|---|---|---|
45 | 45 | 4 | 4 | M | 14 | 45 | 45 | 4 | 4 | M | 17 | xxxxxx |
45 | 45 | 4 | 4 | M | 29 | 45 | 45 | 4 | 4 | M | 28 | xxxxxx |
45 | 45 | 4 | 14 | M | 19 | 45 | 45 | 4 | 14 | M | 18 | xxxxxx |
45 | 45 | 4 | 14 | M | 27 | 45 | 45 | 4 | 14 | M | 26 | xxxxxx |
45 | 45 | 7 | 1 | M | 35 | 45 | 45 | 7 | 1 | M | 34 | xxxxxx |
45 | 45 | 7 | 1 | M | 39 | 45 | 45 | 7 | 1 | M | 38 | xxxxxx |
The total output can be produced, but not in SAS at this time.
I would like to know how to produce in the SAS.
Thanks for your comments,
Dow
The code example I showed would work in your case then, you just need to change the rename parts
data want;
merge have have (rename= (state=state_d county=count_d etc...);
run;
Reeza,
Your help is highly appreciated.
I wish the code that you offered able to get the accurate output.
The only way to find out is to run your code and get outputs.
I cannot run SAS codes now.
I already have the output for the attached two new tables, yet it is not produced in SAS.
I would like to compare other outputs to my output.
Thanks for anyone who may concern.
Dow
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.