Help using Base SAS procedures

Please help with this problem.

Reply
Occasional Contributor
Posts: 18

Please help with this problem.

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

Super User
Posts: 17,819

Re: Please help with this problem.

Occasional Contributor
Posts: 18

Re: Please help with this problem.

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

Valued Guide
Posts: 765

Re: Please help with this problem.

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?

Occasional Contributor
Posts: 18

Re: Please help with this problem.

Please, see my reply to Reeza.

Thanks, MikeZdeb

Dow

Super User
Posts: 17,819

Re: Please help with this problem.

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;

Occasional Contributor
Posts: 18

Re: Please help with this problem.

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

Super User
Posts: 17,819

Re: Please help with this problem.

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;

Occasional Contributor
Posts: 18

Re: Please help with this problem.

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

Ask a Question
Discussion stats
  • 8 replies
  • 252 views
  • 0 likes
  • 3 in conversation