Hi,
I have data just like below
Name | dob |
alexis | 1-Jan-00 |
alexander | 3-Aug-89 |
alexa | 2-Mar-90 |
alex | 3-Aug-89 |
alex | 2-Mar-90 |
alex | 1-Jan-00 |
alex | 1-Jan-00 |
alex | 7-Sep-01 |
and I wanto to give them ID like this
Name | dob | ID |
alexis | 1-Jan-00 | 1 |
alexander | 3-Aug-89 | 2 |
alexa | 2-Mar-90 | 3 |
alex | 3-Aug-89 | 4 |
alex | 2-Mar-90 | 5 |
alex | 1-Jan-00 | 6 |
alex | 1-Jan-00 | 6 |
alex | 7-Sep-01 | 7 |
Please help
Thanks
data want;
set have;
by name dob notsorted;
if first.dob then id+1;
run;
data want;
Set have;
ID=_n_;
Run;
hi behata,
if I want same ID for same name and DOB, I can't use _n_.
do you have any idea?
Thanks
data want;
set have;
by name dob notsorted;
if first.dob then id+1;
run;
@icecubescb please mark @novinosrin solution as the correct answer if it answers your question.
I would consider if NOTSORTED is good usage in this case but otherwise is pretty much the standard response.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.