BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wlierman
Lapis Lazuli | Level 10

I am in the process of trying to "join" two SAS data sets horizontally.

 

Data set 1 header row is                             

CaseID       CaseStatus       County      Date

Data set 1 has 362,559 rows

 

 

Data set 2 header row is

Contact_Person_ID        CaseStatus1       County_T    Date1

Data set 2 has 167,054 rows

 

I want a horizontally set data set so the header looks like

 

CaseID  CaseStatus  County  Date  Contact_Person_ID  CaseStatus1  County_T   Date1

 

I was envisioning that the data set would have 362,559 rows (to accommodate the largest

data set Data set 1.  Then Data set 2 with 167,054 would be "contained" within the 362,559.

 

So I ran this code

Proc sql;
Create Table SASCHART.CASES_CONTACTS_WANT AS
SELECT *
From SASCHART.Epi_Cases_Export, SASCHART.Arias_Contacts_Trace;
run;

But the query produced 129,664,449 rows before I killed the run.

 

How can I just put the two datasets side-by-side

    Data set 1 rows                     Data set 2 rows

        1                                                  1

        2                                                  2

        .                                                   .

        .                                                   .

        .                                                   .

       200000                                        100,000

       .                                                    .

       .                                                    .

      .                                                    167,059

      362559

 

Then there is another tricky step that comes after.

Thank you for your help.

 

wlierman

1 ACCEPTED SOLUTION
5 REPLIES 5
PaigeMiller
Diamond | Level 26

How do you want to join these data sets?

 

There doesn't seem to be an ID variable that exists in both data set. If CaseID existed in both data sets, you could match on CaseID. But that's not the case.

--
Paige Miller
wlierman
Lapis Lazuli | Level 10

The merge created the dataset I was hoping for.

 

Thank you.

 

wlierman

SASified
Calcite | Level 5

The solution is as simple as this:

 

data merged_tables;
  merge table1 table2;
run;

This will create the vertical join as intended.

PeterClemmensen
Tourmaline | Level 20

The Merge Statement with no By Statement does this.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 5377 views
  • 0 likes
  • 5 in conversation