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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.