BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
umesh1
Fluorite | Level 6

Hi All,

 

I have data set as below where I have client_id. I would like to count them as below. I would like to get the count variable as follows

CLIENT_IDCount
1000241
1000401
1000402
1000403
8950608791
8950608792
8950608793
8950608794
8950608795
8950608796
8950608797
8950608798
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If the data is sorted by your id variable you could use:

 

data want;

    set have;

    by client_id;

    if first.client_id then count=1;

    else count+1;

run;

View solution in original post

1 REPLY 1
ballardw
Super User

If the data is sorted by your id variable you could use:

 

data want;

    set have;

    by client_id;

    if first.client_id then count=1;

    else count+1;

run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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