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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: