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: Call for Content

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!

Submit your idea!

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