Organize Date Intervals by weekly

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

Organize Date Intervals by weekly

Help the intern!

I have imported dates when our company has received applications from excel into sas. The dates read as ddmonyyyy in SAS and i'm looking to find how many applications we received since 01jun2016 week by week afterwards. Any ideas on how to do this?

 

libname DESE 'C:\Users\Documents\DESE';
proc import out = DESE.datesreceived
datafile = 'C:\Users\Documents\DESE\DatesReceived.xlsx'
DBMS = xlsx replace;
sheet = 'Sheet1';
getnames = yes;
run;

proc freq data = dese.datesreceived;
table date_received;
run;


Accepted Solutions
Solution
‎07-27-2017 03:50 PM
Super User
Posts: 19,868

Re: Organize Date Intervals by weekly

Apply a week format, untested, you can look up the appropriate format for your needs. To filter after a specified date add a where.

 

proc freq data = dese.datesreceived;
where date_received > '01Jun2016'd; table date_received; format date_received week.; run;

View solution in original post


All Replies
Solution
‎07-27-2017 03:50 PM
Super User
Posts: 19,868

Re: Organize Date Intervals by weekly

Apply a week format, untested, you can look up the appropriate format for your needs. To filter after a specified date add a where.

 

proc freq data = dese.datesreceived;
where date_received > '01Jun2016'd; table date_received; format date_received week.; run;
Occasional Contributor
Posts: 11

Re: Organize Date Intervals by weekly

i'm getting a "ERROR: The format WEEK was not found or could not be loaded" when trying your solution. do you know what could be the problem?

Super User
Posts: 11,343

Re: Organize Date Intervals by weekly

There are three different week formats that may be of Interest WeekU, WeekV and WeekW. Each uses a slightly different count method based on the start of the week and year

WeekU uses Sunday as the first day of the week and number returned is the week within year, range 0-53

WeekV uses Monday as the first day of the week , week 1 is the week that includes both Jan 4 and the first Thursday of the year, returns 01-53

WeekW uses Monday as the first day of the week and returns 00 - 53.

Depending on the width of the format used, min of 2 max 200 and default of 11, you'll get year and day of week information as well.

 

You may want to test the results for the first few days of the year to see which one you may want for your rules. Note that depending on the actual day of the year and year some of the dates may be considered as part of the last week of the previous year.

 

 

Super User
Posts: 19,868

Re: Organize Date Intervals by weekly


ogarduno wrote:

i'm getting a "ERROR: The format WEEK was not found or could not be loaded" when trying your solution. do you know what could be the problem?


untested, you can look up the appropriate format for your needs.

 

http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#p07rezhgdv34...

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 95 views
  • 1 like
  • 3 in conversation