I have a large data set that I'd like to calculate number of "feeding events" by day for 120 individuals across 90 days.
There are anywhere from 90-200 feeding events per day.
Is there a way for SAS to "count" the number of times the EID shows up within the same date
Example:
| 1 | 840003208080904 | 08/22/2019 | 40 |
| 2 | 840003208080904 | 08/22/2019 | 30 |
| 3 | 840003208080904 | 08/22/2019 | 20 |
| 4 | 840003208080904 | 08/22/2019 | 120 |
| 5 | 840003208080905 | 08/22/2019 | 90 |
| 6 | 840003208080905 | 08/22/2019 | 90 |
| 7 | 840003208080905 | 08/22/2019 | 30 |
| 8 | 840003208080906 | 08/22/2019 | 0 |
| 9 | 840003208080906 | 08/22/2019 | 20 |
| 10 | 840003208080906 | 08/22/2019 | 40 |
Count often brings proc Freq into play.
proc freq data=have; tables eid * time /list; run;
is one way. If you want a data set you can add an out=datasetname to the option list after the / .
Several other procedures would work as well.
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.