BookmarkSubscribeRSS Feed
lkr
Calcite | Level 5 lkr
Calcite | Level 5

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.

7 REPLIES 7
Karthikeyan
Fluorite | Level 6

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

lkr
Calcite | Level 5 lkr
Calcite | Level 5

Hi,

thanks for your replies.

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

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

FIRST_NAME     LAST_NAME

Abc                        Def

Your data:

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;

lkr
Calcite | Level 5 lkr
Calcite | Level 5

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?

ChrisNZ
Tourmaline | Level 20

>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.

Ksharp
Super User

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 7 replies
  • 1481 views
  • 0 likes
  • 5 in conversation