BookmarkSubscribeRSS Feed
factorhedge
Fluorite | Level 6

I have 2 tables/datasets , I would like to merge Table 2 with Table 1 and arrive at the output table which looks like Table 3

Table 1 - time series table with year months from 2002 to 2010 (12 months * 9 years) , each Name1 goes for every month and year

Names1CompanyNameCodeYearMonth
AXYZ
AABC
ADEF
BXYZ
BEFH
BJKL
BDEF

Table 2 (each CompanyName has four occurrences)

CompanyNameCodeEarningsDates
XYZJan 2002
XYZApr 2002
XYZJuly 2002
XYZNov 2002

Output table - Table 3 (I want all the columns of table 1) + the earnings dates to be populated for corresponding 'Code' variable.

Name1CompanyNameCodeYearmonthEarningsDates
AxyzMonth1Jan 2002
AxyzMonth1Apr 2002
AxyzMonth1July 2002
AxyzMonth1Nov 2002

Thanks

4 REPLIES 4
Tom
Super User Tom
Super User

Did you try just doing it?  What happened?

pronabesh
Fluorite | Level 6

This is a one to many merge.

The code is simple;

data table_3

     merge table_1 table_2;

     by name1 companyname;

run;

Anotherdream
Quartz | Level 8

Pronabesh your code has a small error. He does not have name1 in data table_2, so remove that from your merge.

data table_3;

merge table_1 Table_2;

by companyname;

run;

pronabesh
Fluorite | Level 6

Yes! Did not notice. Thanks for correcting that.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1684 views
  • 0 likes
  • 4 in conversation