Add Events to Calendar Created with PROC REPORT?

Reply
Occasional Contributor
Posts: 14

Add Events to Calendar Created with PROC REPORT?

Hello, I would like to use SAS to generate a dynamic calendar that displays events.  PROC CALENDAR offers the desired functionality, but I would prefer something with a little more sophisticated appearance.  Searching for other options, I came across this macro (

http://www.devenezia.com/downloads/sas/macros/index.php?m=calendar) from Richard A. DeVenezia.  The macro generates a nice-looking empty calendar using PROC REPORT, but I would like to be able to display events on the calendar.  I have little experience with PROC REPORT and have been unable to figure it out myself.  For example, I thought I could concatenate the day of the month and the event subject into a single character variable and display that character variable instead of the numeric day of the month, but I get the error "ERROR: There is no statistic associated with conc."  Any help would be appreciated.  Thanks! 

Richard DeVenezia's Calendar Macro and Sample Code:

Macro:

/* Richard A. DeVenezia

* http://www.devenezia.com

* 11/28/03

*

* orginally posted to SAS-L Oct 17, 2002

*/

%macro calendar_report (month, year);

  data grid;

  date1 = mdy (&month,1,&year);

  date2 = intnx ('month', date1, 1) - 1;

  do date = date1 to date2;

  wim = intck ('week', date1, date);

  dim = date-date1+1;

  dow = weekday (date);

  output;

  end;

  run;

  proc format;

  value dayname

  1 = 'Sunday'

  2 = 'Monday'

  3 = 'Tuesday'

  4 = 'Wednesday'

  5 = 'Thursday'

  6 = 'Friday'

  7 = 'Saturday'

  ;

  run;

  options missing=' ';

  proc report nowindows data=grid

  style (column) = { just=center cellheight=50pt cellwidth=14.29% just=left vjust=top }

  ;

  column wim ("%sysfunc(mdy(&month,1,&year), monname) &year" dow, dim) ;

  define wim / group noprint ;

  define dow / across ' ' format=dayname. order=internal;

  define dim / ' ';

  run;

  options missing='.';

%mend;

Sample Code:

ods html body='c:\temp\calendar.html' style=sasweb;

%calendar_report (9,2002);

data caldat;

date=mdy(9,13,2002);

subject='John Doe';

visit='1 mos';

duration=1;

output;

run;

ods html style=default;

proc calendar data=caldat formchar(12)=' ';

start date;

dur duration;

run;

ods html close;

UNSUCCESSFUL Code Attempt to Display Dates on PROC REPORT Calendar Based on the Macro Above:

data grid;

    date1 = mdy (4,1,2014);

    date2 = intnx ('month', date1, 1) - 1;

    do date = date1 to date2;

      wim = intck ('week', date1, date);

      dim = date-date1+1;

      dow = weekday (date);

   dim_str = trim(left(put(dim, $8.)));

      output;

    end;

  run;

  proc format;

    value dayname

    1 = 'Sunday'

    2 = 'Monday'

    3 = 'Tuesday'

    4 = 'Wednesday'

    5 = 'Thursday'

    6 = 'Friday'

    7 = 'Saturday'

    ;

  run;

data caldat; length subject $10;

date=mdy(4,15,2014);

subject='Tax Day';

duration=1;

output;

date=mdy(4,20,2014);

subject='Easter';

duration=1;

output;

run;

proc sql; create table cal_mstr as select * from grid as a left join caldat as b on a.date=b.date;

quit;

data cal_mstr; length conc $50; set cal_mstr;

conc = catx(" ", dim_str, subject);

run;

options missing=' ';

  proc report nowindows data=cal_mstr

    style (column) = { just=center cellheight=50pt cellwidth=14.29% just=left vjust=top  };

    column wim ("%sysfunc(mdy(4,1,2014), monname) 2014" dow, conc);

  define wim / group noprint ;

    define dow / across ' '  format=dayname. order=internal;

  define conc / display;

  run;

Super User
Posts: 10,516

Re: Add Events to Calendar Created with PROC REPORT?

Are you looking to add abitrary events of arbitrary length, i.e. "Jim's Camping Trip" 8 days such that the text appears in each of those consecutive days on the resulting calendar? Will there ever be overlaps that both need displays, such as Jim's Camping Trip coincides with the Fourth of July?

Occasional Contributor
Posts: 14

Re: Add Events to Calendar Created with PROC REPORT?

Thanks for your reply!  This is for a high-level 'key events calendar' to remind a group of internal users of upcoming events.  It does not need to be as detailed as someone's personal Outlook calendar.  It just needs to alert users to, at most, a few events per month.


Are you looking to add arbitrary events of arbitrary length, i.e. "Jim's Camping Trip" 8 days such that the text appears in each of those consecutive days on the resulting calendar?


     Yes, if possible, that would work well for our needs!


Will there ever be overlaps that both need displays, such as Jim's Camping Trip coincides with the Fourth of July?


     Yes, there could be multiple events on the same day.


I appreciate your help!

Ask a Question
Discussion stats
  • 2 replies
  • 290 views
  • 0 likes
  • 2 in conversation