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