I am trying to get consecutive repeating name based on a specific id and then get the current_count and total_count (repeat). I need solution based on proc sql only. Thanks
| Name | ID | group id | ||
| QSAVE | 4097 | 3 | ||
| OPEN | 4097 | 3 | ||
| OPEN | 4097 | 3 | ||
| QSAVE | 4097 | 3 | ||
| OPEN | 4097 | 3 | ||
| PASTECLIP | 8193 | 3 | ||
| MTEDIT | 4097 | 3 | ||
| GRIP_STRETCH | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| MATCHPROP | 8193 | 3 | ||
| COPY | 8193 | 3 | ||
| TEXTEDIT | 8193 | 3 | ||
| TEXTEDIT | 8193 | 3 | ||
| MOVE | 8193 | 3 | ||
| GRIP_STRETCH | 8193 | 3 | ||
| MOVE | 8193 | 3 | ||
| ZOOM | 8193 | 3 | ||
| QSAVE | 4097 | 3 | ||
| OPEN | 4097 | 3 | ||
| PASTECLIP | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| CHPROP | 8193 | 3 | ||
| MATCHPROP | 8193 | 3 | ||
| MATCHPROP | 8193 | 3 | ||
| CUTCLIP | 4097 | 3 | ||
| PASTEBLOCK | 8193 | 3 | ||
| CUTCLIP | 4097 | 3 | ||
| PASTEBLOCK | 8193 | 3 | ||
| what i want | ||||
| Name | ID | group id | repeat | |
| CHPROP | 8193 | 3 | 2 | |
| CHPROP | 8193 | 3 | 2 | |
| TEXTEDIT | 8193 | 3 | 2 | |
| TEXTEDIT | 8193 | 3 | 2 | |
| CHPROP | 8193 | 3 | 9 | |
| CHPROP | 8193 | 3 | 9 | |
| CHPROP | 8193 | 3 | 9 | |
| CHPROP | 8193 | 3 | 9 | |
| CHPROP | 8193 | 3 | 9 | |
| CHPROP | 8193 | 3 | 9 | |
| CHPROP | 8193 | 3 | 9 | |
| CHPROP | 8193 | 3 | 9 | |
| CHPROP | 8193 | 3 | 9 | |
| MATCHPROP | 8193 | 3 | 2 | |
| MATCHPROP | 8193 | 3 | 2 |
Proc SQL is extremely difficult to work with data in a specific order. It just is not designed to do so.
I suspect that you would have to add some variables first in a data step or two to add "group by" values but by that time you would have been better off to do the counting in those data steps.
Does the GroupID variable you show play any role in the result? From your description I don't believe so but cant tell. All I "know" is every value of GroupId is 3, or possibly "3"
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 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.