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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 23842 views
  • 0 likes
  • 2 in conversation