Example 1: Example: Publishing in the DATA Step

The following example builds a package, explicitly publishes to two queues, and then publishes to a channel that is defined in the SAS Metadata Repository. This example uses the DATA step, but easily can be changed to use the macro interface.
filename f 'c:\frame.html';
filename c 'c:\contents.html';
filename p 'c:\page.html';
filename b 'c:\body.html';
ods html frame = f contents =c(url="contents.html")
   body = b(url="body.html") page=p(url="page.html");

/* run some data steps/procs to generate ODS output */
data b;
   do i= 1 to 1000;
   output;
end;
run;

data emp;
input fname $ lname $ ages state $ siblings;
cards;
Steph Lyons 32 NC 4
Richard Jones 40 NC 2
Mary White 74 NC 1
Kai Burns 3 NC 1
Dakota Nelson 1 NC 1
Paul Black 79 NC 8
Digger Harris 5 NC 0
Coby Thomas 1 NC 0
Julie Mack 6 NC 1
Amy Gill 3 NC 1
Brian Meadows 16 HA 1
Richard Wills 17 HA 1
Diane Brown 48 CO 4
Pamela Smith 42 HA 4
Joe Thompson 44 WA 10
Michael Grant 23 IL 1
Michael Ford 31 NM 4
Ken Bush 28 NC 1
Brian Carter 27 NC 1
Laurie Clinton 32 NC 1
Kevin Anderson 33 NC 1
Steve Kennedy 33 NC 1
run;
quit;

proc print;run;
proc contents;run;
ods html close;

data _null_;
   rc=0;a='a';b='b';c='c';d='d';
   length filename $64 mimeType $24 fileType
      $10 nameValue $100 description $100;

   packageId = 0;
   nameValue="type=(test) coverage=(filtering,
      transports)";
   CALL PACKAGE_BEGIN(packageId,"Main results package.",
      nameValue, rc);
   if (rc eq 0) then put 'Package begin successful.';
   else do;
      msg = sysmsg();
      put msg;
   end;

   gifpid=0;
   CALL PACKAGE_BEGIN(gifpid,"Gif nested package.",'', rc);
   if (rc eq 0) then put 'Gif package begin successful.';
   else do;
      msg = sysmsg();
      put msg;
   end;

   nameValue="type=report, topic=census";
   description="North Carolina residents.";
   libname = "WORK";
   memname="EMP";
   CALL INSERT_DATASET(packageId, libname, memname,
      description, nameValue, rc);
   if rc ne 0 then do;
      msg = sysmsg();
      put msg;
   end;
   else
      put 'Insert data set successful.';

   CALL INSERT_HTML(packageId,"fileref:b", "",
      "fileref:f", "",
      "fileref:c", "",
      "fileref:p", "", "ODS HTML Output",'', rc);
   if rc ne 0 then do;
      msg = sysmsg();
      put msg;
   end;
   else
      put 'Insert html successful.';

   CALL INSERT_DATASET(packageId,"WORK","b",
      "B dataset...",'', rc);
   if rc ne 0 then do;
      msg = sysmsg();
      put msg;
   end;
   else
      put 'Insert data set successful';

   /* insert package (nested package */
   CALL INSERT_PACKAGE(packageId, gifpid,rc);
   if rc eq 0 then put 'Insert package successful';
   else do;
      msg = sysmsg();
      put msg;
   end;

   description = "Gif for marketing campaign.";
   filename = "filename:campaign01.01.gif";
   fileType = "Binary";
   mimeType = "Image/Gif";
   CALL INSERT_FILE(gifpid, filename, fileType,
      mimeType, description,'', rc);
   if rc ne 0 then do;
      msg = sysmsg();
      put msg;
   end;
   else
      put 'Insert file (gif) successful.';

   description = "Test VRML file.";
   filename = "filename:test.wrl";
   fileType = "text";
   mimeType = "model/vrml";
   CALL INSERT_FILE(packageId,filename, fileType,
      mimeType, description,'', rc);
   if rc ne 0 then do;
      msg = sysmsg();
      put msg;
   end;
   else
      put 'Insert file (vrml) successful.';

   /* send package to the two queues that are specified */
   properties='';
   CALL PACKAGE_PUBLISH(packageId, "TO_QUEUE", rc, properties,
      "MQSERIES://JSMITH.LOCAL", "MSMQ://JSMITH\transq");
   if rc ne 0 then do;
      msg = sysmsg();
      put msg;
   end;
   else
      put 'Publish successful';

   /* publish to the filter test channel
      defined in the SAS Metadata Repository */
   storeinfo=
      "SAS-OMA://alpair01.sys.com:8561";
   channel1= 'FilterTest1';
   properties='channel_store, subject, metauser, metapass';
   subject="Filter Testing Results";
   user = "myUserName";
   password = "myPassword";
   CALL PACKAGE_PUBLISH(packageId, "TO_SUBSCRIBERS", rc,
      properties, storeinfo, subject, user, password,
      channel1);
   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 end successful';
run;
quit;