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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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