BookmarkSubscribeRSS Feed
OLUGBOJI
Obsidian | Level 7

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  
1 REPLY 1
ballardw
Super User

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"

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 723 views
  • 1 like
  • 2 in conversation