In reply to Leonid Batkhan.

Yes similar, but you don't need to build the indexes for the loop, just use the fetch to fetch each row from the table.

You could also simplify further and remove the getvarc if you use %syscall set(dsid);. Like this:

/* get number of countries */
%let dsid = %sysfunc(open(work.countries));

%syscall set(dsid);

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

%let cntry=&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));