Dear programmers,
How can I count a fixed variable in an easy way?
What I have is:
| WELL_NAME |
| A |
| A |
| A |
| A |
| A |
| A |
| A |
| A |
| A |
| B |
| B |
| C |
| C |
| C |
| C |
| C |
| C |
| C |
| C |
| D |
| D |
| E |
| E |
| E |
| E |
| E |
| E |
| F |
| F |
| F |
| F |
| F |
| F |
| F |
| F |
What I want is:
| WELL_NAME | COUNT |
| A | 1 |
| A | 2 |
| A | 3 |
| A | 4 |
| A | 5 |
| A | 6 |
| A | 7 |
| A | 8 |
| A | 9 |
| B | 1 |
| B | 2 |
| C | 1 |
| C | 2 |
| C | 3 |
| C | 4 |
| C | 5 |
| C | 6 |
| C | 7 |
| C | 8 |
| D | 1 |
| D | 2 |
| E | 1 |
| E | 2 |
| E | 3 |
| E | 4 |
| E | 5 |
| E | 6 |
| F | 1 |
| F | 2 |
| F | 3 |
| F | 4 |
| F | 5 |
| F | 6 |
| F | 7 |
| F | 8 |
Best regards
Farshid
Simple application of BY group processing.
data want;
set have;
by well_group;
count+1;
if first.well_group then count=1;
run;
Simple application of BY group processing.
data want;
set have;
by well_group;
count+1;
if first.well_group then count=1;
run;
This outlines how you can do this:
https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.