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"

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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