Good stuff Leonid. I have found the scl functions in macro and datastep very useful over the years.

If you use the "fetch" function to loop through your driver table you can simplify the code. You no longer need the data _null_.

/* output files location */
filename odsout "C:\temp";

/* get unique countries */
proc sort data=sashelp.prdsale(keep=COUNTRY) out=work.countries nodupkey;
by COUNTRY;
run;

%macro loop;

%local num i cntry;

/* get number of countries */
%let dsid = %sysfunc(open(work.countries));
%let num = %sysfunc(attrn(&dsid,nlobs));

%do %while(%sysfunc(fetch(&dsid)) = 0);

%let cntry=%sysfunc(getvarc(&dsid,%sysfunc(varnum(&dsid,COUNTRY))));

ods html path=odsout file="report_&cntry..html" style=styles.seaside;
goptions reset=all device=actximg colors=() htext=9pt hsize=5in vsize=3in;
title1 "Product sales by year for &cntry";
axis1 minor=none label=('Actual Sales');

proc gchart data=sashelp.prdsale(where=(COUNTRY eq "&cntry"));
vbar YEAR /
sumvar = ACTUAL
width = 10
outside = sum
raxis = axis1
cframe = white nozero discrete
;
format ACTUAL dollar12.0;
run;
quit;

%end;

%let rc = %sysfunc(close(&dsid));

ods html close;

%mend loop;
%loop;