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_ID | Count |
100024 | 1 |
100040 | 1 |
100040 | 2 |
100040 | 3 |
895060879 | 1 |
895060879 | 2 |
895060879 | 3 |
895060879 | 4 |
895060879 | 5 |
895060879 | 6 |
895060879 | 7 |
895060879 | 8 |
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;
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;
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!
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.