I am trying to create a sequence number to enumerate the total number of visits to a service (I cannot delete duplicates because of other variables).
I already have a variable that indicates if the client presented unique visits. Therefore, the sequence number should enumerate all visits but keep the same number when any client does not present a unique visit.
I hope you can help me with this since I'm quite new in SAS. Thank you!!
| ID | Unique_visit | Total_visits (NEEDED) |
| 1 | 1 | 1 |
| 1 | 1 | 2 |
| 1 | 0 | 2 |
| 2 | 1 | 3 |
| 2 | 1 | 4 |
| 3 | 1 | 5 |
| 3 | 0 | 5 |
| 3 | 1 | 6 |
| 4 | 1 | 7 |
| 4 | 1 | 8 |
| 4 | 0 | 8 |
| 4 | 1 | 9 |
data want;
set have;
Total_visits +unique_visit;
run;
data want;
set have;
Total_visits +unique_visit;
run;
I cannot believe that I was overthinking this. Thank you so much!!
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 lock in 2025 pricing—just $495!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.