Example 4: Sample SAS Program with an HTML Viewer

The following SAS program example includes two parts:
  • SAS code that creates two SAS data sets
  • package publishing CALL routines that create a package, insert package entries, and publish the package to e-mail with the aid of a viewer file
The PACKAGE_PUBLISH CALL routine applies a viewer that is named realview.html to the package that is rendered in e-mail. The following code shows the viewer properties and attributes. To look at the content of the viewer template, see Sample Viewer Template. To look at a rendered view of the package that is delivered to e-mail, see the output from the viewer coding sections that are described in How to Create a Viewer. The e-mail output from this sample HTML viewer is a collection of the output from these sections.
data empInfo;
length homePage $256;
input fname $ lname $ ages state $ siblings homePage $;
datalines;
John Smith 32 NY 4 http://alphaliteairways.com/~jsmith
Gary DeStephano 20 NY 2 http://alphaliteairways.com/~gdest
Arthur Allen 40 CA 2 http://alphaliteairways.com/~aallen
Jean Forest 3 CA 1 http://alphaliteairways.com/~jforest
Tony Votta 30 NC 2 http://www.pizza.com/~tova
Dakota Smith 3 NC 1 http://~alphaliteairways.com/~dakota
;
run;
quit;

data fileInfo;
length fileName $256;
input fileName $;
datalines;
Sales
Marketing
R&D
;
run;
quit;

data _null_;
rc=0; packageId = 0;

CALL PACKAGE_BEGIN(packageId,"Daily Orders Report.",'', rc);
if (rc eq 0) then put 'Package begin successful.';
else do;
   msg = sysmsg();
   put msg;
end;

CALL INSERT_REF(packageId, "HTML",
   "http://www.alphaliteairways.com",
"Check out the Alphalite Airways Web site
   for more information." , "", rc);
if (rc eq 0) then put 'Insert Reference successful.';
else do;
   msg = sysmsg();
   put msg;
end;

CALL INSERT_DATASET(packageId, "work", "empInfo",
   "Data Set empInfo" , "", rc);
if (rc eq 0) then put 'Insert Data Set successful.';
else do;
   msg = sysmsg();
   put msg;
end;

CALL INSERT_DATASET(packageId, "work", "fileInfo",
   "Data Set fileInfo" , "", rc);
if (rc eq 0) then put 'Insert Data Set successful.';
else do;
   msg = sysmsg();
   put msg;
end;

viewerName='filename:realview.html';
prop='VIEWER_NAME';
address="John.Smith@alphaliteairways.com";
CALL PACKAGE_PUBLISH(packageId, "TO_EMAIL", rc,
   prop, viewerName, address);
if rc ne 0 then do;
   msg = sysmsg();
   put msg;
end;
else
   put 'Publish successful';

CALL PACKAGE_END(packageId,rc);
if rc ne 0 then do;
   msg = sysmsg();
   put msg;
end;
else
   put 'Package termination successful';

run;