BookmarkSubscribeRSS Feed
abro0528
Calcite | Level 5

Hello, I'm trying to create a variable that will flag when a facility (such as a school or hospital) had no prior cases of a disease for a month prior to today's date.

 

The dataset is organized with a facility name(name, string), a collection date(MM/DD/YYYY) and a number of cases (cases, integer) on each line, and the collection dates can be irregular, some facilities may report daily, some may report weekly. What I am trying to do, essentially, is aggregate the total number of cases for each facility within this timeframe. I've figured out the timeframe but I'm not sure the best way to aggregate it.

 

new_date= input(collectiondate, mmddyy10.);
format new_date mmddyy10.;
start_timeframe= intnx('week', today(), -5, 'same'); *represents cutoff for prior months;
end_timeframe= intnx('week', today(), -1, 'same'); *cutoff for current week;

prior_recent= end_timeframe-new_date;
if prior_recent > 28 then timeframe = 0; *0 represents a timeframe approximately 5 weeks away from current date;
else if prior_recent < 0 then timeframe = 1; *1 represents a timeframe occuring between 4 and 1 weeks prior to the current date;
else timeframe = -1; * -1 represents current data within 1 week of the application being run;
if timeframe = 0 then delete; *removes old data;

 



Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 0 replies
  • 568 views
  • 0 likes
  • 1 in conversation