New Contributor
Posts: 3

# Matching two values, then combining them.

I have the following data:

Number     Note               Responsible person

1               First Name 2   First Last Name 1

2               First Name 1   First Last Name 2

I would like a program where the result is the following data:

Number     Note          Responsible person     New responsible person

1               First Name 2   First Last Name 1   First Last Name 2

2               First Name 1   First Last Name 2   First Last Name 1

Can anyone at least point me towards which functions I can use?

I have tried arrays without any luck.

Thanks,

Lars.

Contributor
Posts: 37

## Re: Matching two values, then combining them.

Will you be more specific ? what is it you trying to match and how do you want to arrive at "New responsible person"?

Super User
Posts: 9,599

## Re: Matching two values, then combining them.

Sorry, you will need to clarify your problem somewhat.  post test data in the form of a datastep, and required output.  How is New responsible person arrived at because from the test data you have given:

data want;

set have;

new_responsible_person=note;

run;

Will give that response.

New Contributor
Posts: 3

## Re: Matching two values, then combining them.

Hi,

new_responsible_person=note will only give the First name.

What I need is a list of "Responsible persons" and when the First Name in Note finds a match in that list, it takes the First AND Last Name and puts it into a new list.

Super User
Posts: 9,599

## Re: Matching two values, then combining them.

Hi,

Yes, still not clear.  Maybe you want something like a lookup table:

FIRST_NAME     LAST_NAME

Abc                        Def

FIRST_NAME     RESP_PERSON

Abc                       Abc

You want:

FIRST_NAME     RESP_PERSON     NEW_RESP_PERSON

Abc                       Abc                             Abc Def

If so then you could do it many ways (merge, join, hash) or if smaller data then:

proc sql;

create table WANT as

select     A.*,

(select cats(FIRST_NAME," ",LAST_NAME) from LOOKUP where A.FIRST_NAME=FIRST_NAME) as NEW_RESP_PERSON

from       HAVE A;

quit;

New Contributor
Posts: 3

## Re: Matching two values, then combining them.

Thanks.

How do I make it more clear?

I'm not used to datasteps as I use Enterprise Guide so what I was looking for was just a pointer on where to get started, which you gave me above, but am I not allowed to ask questions of that "type" here?

PROC Star
Posts: 2,369

## Re: Matching two values, then combining them.

>What I need is a list of "Responsible persons" and when the First Name in Note finds a match in that list, it takes the First AND Last Name and puts it into a new list.

You have to try harder. As stated, your goal is not clear. Give complete explanations and examples. The above sentence is too vague.

Super User
Posts: 10,784

## Re: Matching two values, then combining them.

Are you trying to search a tree or a graph ? Check this:

Discussion stats
• 7 replies
• 393 views
• 0 likes
• 5 in conversation