/*--This program requires SAS 9.4--*/ %macro GapMinder(start=, end=, incr=); %do year=&start %to &end %by &incr; proc sgplot data=GapMinder noautolegend; format gdp dollar12.0; footnote j=l 'Created using the SGPLOT Procedure'; where yearnum=&year; format name $name.; bubble x=gdp y=lifeExpectancy size=population / group=region datalabel=name datalabelattrs=(size=12 weight=bold) dataskin=gloss bradiusmin=2 bradiusmax=50; inset "&year" / position=bottomright textattrs=(size=60 weight=bold color=lightgray); xaxis type=log offsetmin=0.05 offsetmax=0.08 logstyle=linear grid min=100 max=60000; yaxis offsetmin=0.05 offsetmax=0.05 grid min=30 max=90; run; %end; %mend GapMinder; /*--Set display labels only for a few countries--*/ data GapMinder; set sasuser.GapMinder(where=(population > 1e6)); if (country in ('United States', 'India', 'China')) then name=country; yearnum=year(date); run; /*--Set formats--*/ proc format; value $name 'United States' = 'USA' 'China'='China' ; /*--Create animation--*/ options papersize=('5 in', '3 in') printerpath=gif animation=start animduration=0.1 animloop=yes noanimoverlay; ods printer file='GapMinder.gif'; ods graphics / width=5in height=3in imagefmt=GIF; %GapMinder(start=1960, end=2006, incr=2); %GapMinder(start=2006, end=1960, incr=-2); options printerpath=gif animation=stop; ods printer close;