/**********************************************************************/ /* Annotate Facility Program */ %macro cal(mon,yr); title1 h=5 pct f=zapf "&mon &yr"; data calendar; length text $ 20 function $8; xsys='5'; ysys='5'; color='black '; /*****************************/ /* */ /* Draw calendar grid lines */ /* */ /*****************************/ /* draw horizontal grid lines */ do y=0 to 90 by 18; x=0; function='move'; output; line=1; x=100; function='draw'; output; end; /* draw vertical grid lines */ do x=0 to 100 by 20; y=0; function='move'; output; y=100; function='draw'; output; end; /* set line style to dashed and draw top line */ line=2; x=0; y=100; function='move'; output; x=100; y=100; function='draw'; output; /*************************/ /* */ /* Draw weekday headings */ /* */ /*************************/ position='5'; hsys='5'; size=4; function='label'; style='zapf '; x=10; y=96 ; text='Monday'; output; x=30; y=96 ; text='Tuesday'; output; x=50; y=96 ; text='Wednesday'; output; x=70; y=96 ; text='Thursday'; output; x=90; y=96 ; text='Friday'; output; /*******************************/ /* */ /* Fill in dates in calendar */ /* */ /*******************************/ /* set size and color for text */ color='cyan'; size=15; /* calculate first and last day of month */ dt=%unquote(%quote(%'01&mon&yr%'d)); lastday=intnx('month',dt,1)-1; week=1; /* for each day, determine what day of week it */ /* is, then place the text accordingly */ do day=dt to lastday; n+1; /* day of week */ wkday=weekday(day); /* wk of month */ if wkday=2 and n gt 3 then week+1; /* no weekends */ if wkday ne 1 and wkday ne 7 then do; /* x coordinate */ x=20*(wkday-2)+ 9; /* y coordinate */ y=90-(18*week)+12; text=put(day(day),2.); output; end; end; run; /* produce the graph */ proc gslide annotate=calendar; run; quit; %mend cal; %cal(JAN,92); /**********************************************************************/ /* DSGI Program */ %macro cal(mon,yr); title1 h=5 pct f=zapf "&mon &yr"; data _null_; rc=ginit(); rc=graph('clear'); /****************************/ /* */ /* Draw calendar grid lines */ /* */ /****************************/ /* Set up window in screen pct (excluding */ /* title space) */ rc=gset('window',1,0,0,100,100); rc=gset('transno',1); /* Color 1 is for grid lines and column */ /* headings. Color 2 is for the days */ rc=gset('colrep',1,'black'); rc=gset('colrep',2,'cyan'); rc=gset('lincolor',1); rc=gset('texcolor',1); /* set line style to solid */ rc=gset('lintype',1); /* draw horizontal grid lines */ do y=0 to 90 by 18; rc=gdraw('line',2,0,100,y,y); end; /* draw vertical grid lines */ do x=0 to 100 by 20; rc=gdraw('line',2,x,x,0,100); end; /* set line style to dashed and draw top line */ rc=gset('lintype',2); rc=gdraw('line',2,0,100,100,100); /***************************/ /* */ /* Draw weekday headings */ /* */ /***************************/ rc=gset('texfont','zapf'); rc=gset('texalign','center','half'); rc=gset('texheight',3.2); rc=gdraw('text',10,96,'Monday'); rc=gdraw('text',30,96,'Tuesday'); rc=gdraw('text',50,96,'Wednesday'); rc=gdraw('text',70,96,'Thursday'); rc=gdraw('text',90,96,'Friday'); /*****************************/ /* */ /* Fill in dates in calendar */ /* */ /*****************************/ /* reset text color and height to draw the days */ rc=gset('texcolor',2); rc=gset('texheight',15); /* calculate first and last day of the month */ dt=%unquote(%quote(%'01&mon&yr%'d)); lastday=intnx('month',dt,1)-1; week=1; /* For each day, determine what day of week it */ /* is. Then place the text accordingly */ do day=dt to lastday; n+1; /* day of week */ wkday=weekday(day); /* week of month */ if wkday=2 and n gt 3 then week+1; /* no weekends */ if wkday ne 1 and wkday ne 7 then do; /* x coordinate */ x=20*(wkday-2)+9; /* y coordinate */ y=90-(18*week)+12; rc=gdraw('text',x,y,put(day(day),2.)); end; end; /* produce the graph */ rc=graph('update'); rc=gterm(); run; %mend cal; %cal(JAN, 92); /**********************************************************************/