BookmarkSubscribeRSS Feed
DowChang
Calcite | Level 5

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

8 REPLIES 8
DowChang
Calcite | Level 5

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

MikeZdeb
Rhodochrosite | Level 12

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?

DowChang
Calcite | Level 5

Please, see my reply to Reeza.

Thanks, MikeZdeb

Dow

Reeza
Super User

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;

DowChang
Calcite | Level 5

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.

StateCountyMonthDaySexAgeState_DCounty_DMonth_DDay_DSex_DAge_DObs
454544M14454544M17xxxxxx
454544M29454544M28xxxxxx
4545414M194545414M18xxxxxx
4545414M274545414M26xxxxxx
454571M35454571M34xxxxxx
454571M39454571M38xxxxxx

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

Reeza
Super User

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;

DowChang
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 935 views
  • 0 likes
  • 3 in conversation