I am working on writing a program that will produce summary level data by county for a rare event by utilizing a loop macro. The initial dataset I am working out of contains only events, no non-events. I have a rolling 3 year window that is currently summarized by month (within a specific county) by using proc means to get the count by month from the initial dataset, and then outputting the results as a dataset. I then use proc means on the resulting data step in my previous sentence to get the standard deviation of the count by month. The problem I am running into is that within most counties, this event does not occur each month. So, when I try to use proc means to get the standard deviation it only recognizes the months where the count is at least 1, the standard deviation is wrong as the N does not account for the months missing, as there was no event. How can I add an observation to the data set the number of events to 0, so that the standard deviation will be accurate? I want to change the example in 'Current dataset' below, to look like 'Goal dataset'. In my example, month 4 is not in 'Current dataset' as there are 0 events that month. Essentially I want to tell SAS that month 4 is missing so set sum to 0. But, this cannot be hardcoded as it will not always be month 4 that has 0 observations. Note that my actual full dataset includes 36 months, but for interest of space I am only including 6 months below to demonstrate my goal. Current dataset for county X: Month Sum 1 2 2 1 3 1 5 3 6 2 Goal dataset for county X: Month Sum 1 2 2 1 3 1 4 0 5 3 6 2 Thank you very much in advance!!
... View more