BookmarkSubscribeRSS Feed
CMPSU
Calcite | Level 5

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:

 

             EID                         TIME           Consumed
184000320808090408/22/201940 
284000320808090408/22/201930 
384000320808090408/22/201920 
484000320808090408/22/2019120 
584000320808090508/22/201990 
684000320808090508/22/201990 
784000320808090508/22/201930 
884000320808090608/22/20190 
984000320808090608/22/201920 
1084000320808090608/22/201940 
 
 
2 REPLIES 2
ballardw
Super User

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.

CMPSU
Calcite | Level 5
This worked! follow up question: How can a calculate average of # observations per day

EXAMPLE: 840003208080904 had and average of 34 recorded events /day across all 100 days
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 734 views
  • 0 likes
  • 2 in conversation