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.
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.