DATA Step, Macro, Functions and more

adding multiple rows to multiple rows

Reply
Regular Learner
Posts: 1

adding multiple rows to multiple rows

I have 2 files that look like this:

 

CustID ContactID

1              1

1              2

1              3

 

CustID PlanID

1             A

1             B

1             C

 

I need to merge them in base SAS so I get the following:

 

CustID ContcatID PlanID

1                1             A

1                1             B

1                1             C

1                2             A

1                2             B

1                2             C

1                3             A

1                3             B

1                3             C

Regular Contributor
Posts: 194

Re: adding multiple rows to multiple rows

[ Edited ]
Posted in reply to granthecht

You might lookup Cartesian Products in SAS.

PROC Star
Posts: 1,190

Re: adding multiple rows to multiple rows

Posted in reply to granthecht

like this?

 

data one;
input CustID ContactID;
datalines;
1 1
1 2
1 3
;

data two;
input CustID PlanID$;
datalines;
1 A
1 B
1 C
;

proc sql;
	create table want as
	select one.*
	      ,two.planID
	from one, two
	where one.CustID=two.CustID
	order by CustID, ContactID, planID;
quit;
Contributor
Posts: 54

Re: adding multiple rows to multiple rows

Posted in reply to granthecht
You can also use "inner join" or "left join" clauses with proc sql
Ask a Question
Discussion stats
  • 3 replies
  • 57 views
  • 0 likes
  • 4 in conversation