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"
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.