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.
Will you be more specific ? what is it you trying to match and how do you want to arrive at "New responsible person"?
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.
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.
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;
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?
>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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.