Working 9 to 17 is the new working 9 to 5. Happy Labor Day!
* Fun With SAS ODS Graphics: Working 9 to 17 (Labor Day 2023);
data clock; * Generate points for chart;
pi=constant('pi');
do hour=0 to 23; * Generate points for 24 hours;
Xhr=sin(hour/24*2*pi); * X, Y for hour numbers;
Yhr=cos(hour/24*2*pi);
Xm=.9*Xhr; * X, Y for hour markers (circles);
Ym=.9*Yhr;
txt=compress(put(hour,2.)); * Convert hour to text;
angle=360-hour/24*360; * Compute angle to display hour on perpindicular;
output;
end;
txt2="HAPPY*LABOR DAY!"; x2=0; y2=0; output; * Put Happy Labor Day message in center of circle;
Xhr=.; xm=.; x2=.; * Generate a polygon to shade hours between 9 to 17 ("9 to 5" job!);
id=1; x9to17=0; y9to17=0; output; * Start polygon at center (0,0);
do hour=9 to 17 by .1; * Add points on circle from hours 9 to 17;
x9to17=1.15*sin(hour/24*2*pi);
y9to17=1.15*cos(hour/24*2*pi);
output;
end;
* Generate the "Working 9 to 17" chart;
ods graphics on / reset antialias height=6in width=6in;
proc sgplot data=clock aspect=1 noautolegend noborder subpixel;
polygon x=x9to17 y=y9to17 id=id / fill fillattrs=(color=lightgrey) lineattrs=(color=lightgrey); * Shade hours between 9 and 17;
scatter x=Xm y=Ym / markerattrs=(symbol=circlefilled size=8pt); * Add hour markers (circles);
ellipseparm semimajor=1.15 semiminor=1.15 / nofill lineattrs=(color=black thickness=3pt); * Draw circle border;
text x=Xhr y=Yhr text=txt / rotate=angle contributeoffsets=none strip textattrs=(size=20pt weight=bold); * Draw hours at an angle;
text x=x2 y=y2 text=txt2 / contributeoffsets=none strip textattrs=(size=32pt weight=bold) splitchar='*' splitpolicy=splitalways; * Happy Labor Day message;
xaxis display=none; * Suppress axes;
yaxis display=none;
run;
Tweak formula to angle=360-hour/24*360-180*(7<=hour<=17) to make bottom hours right-side up like this neat Svalbard Arctic FL24 watch. 😀
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.