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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.