BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cho16
Obsidian | Level 7

 Hello team,

 

We have two tables 1 and 2. The PRV is the primary key.

We should display only the equal LOB values from the two tables. For example , in table 1  the PRV 1 has the LOB value EPA and table 2 has two different values EPA and HPL. But it should display as EPA  in table 2.

 

Table 1 :

PRV

LOB

EXP

porg

1

EPA

99999

1

1

EPA

99999

2

2

EPA

99999

3

2

EPC

99999

4

3

EPA

99999

5

3

HPL

99999

6

 

Table 2:

PRV

LOB

EXP

Parent

1

EPA

99999

G

1

HPL

99999

H

2

EPA

99999

J

2

EPC

99999

I

3

EPA

99999

O

3

HPL

99999

O

 

Results:

PRV

LOB

EXP

Parent

1

EPA

99999

G

2

EPA

99999

J

2

EPC

99999

I

3

EPA

99999

O

3

HPL

99999

O

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
r_behata
Barite | Level 11
Proc SQL;
	Create table want as 
		Select b.*
		from table1 a,
			table2 b
		where a.prv=b.prv
		and a.lob=b.lob;
Quit;

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

@cho16 wrote:

 

We have two tables 1 and 2. The PRV is the primary key.

We should display only the equal LOB values from the two tables. For example , in table 1  the PRV 1 has the LOB value EPA and table 2 has two different values EPA and HPL. But it should display as EPA  in table 2.


Why? What is the logic here? In order for us to write code, you need to explain the logic and general rules we can follow to create a program that works in all cases.

--
Paige Miller
cho16
Obsidian | Level 7

I have a requirement to compare the two datasets with different variables. There is a primary key called PRV. If there are records that has two different values on the variable LOB for the one PRV, then it should display with the same record  on the table 2 as shown in the above example.

r_behata
Barite | Level 11
Proc SQL;
	Create table want as 
		Select b.*
		from table1 a,
			table2 b
		where a.prv=b.prv
		and a.lob=b.lob;
Quit;

hackathon24-white-horiz.png

Join the 2025 SAS Hackathon!

Calling all data scientists and open-source enthusiasts! Want to solve real problems that impact your company or the world? Register to hack by August 31st!

Register Now

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
  • 3 replies
  • 875 views
  • 0 likes
  • 3 in conversation