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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: