Contents Publish Package Interface Previous Next

Example: Publishing in a Macro

The following example builds a package, and then publishes the package to a channel defined within the LDAP directory and then explicitly publishes to one queue.

This example uses macro variables rather than the DATA step, which allows you the flexibility to use CALL routines throughout your code, as other processing completes.

This example illustrates how publish CALL routines are used with other SAS statements.

%macro chkrc(function);
%if &rc = 0 %then %put "NOTE: &function succeeded.";
%else %do;
   %let msg= %sysfunc(sysmsg());
   %put &function failed - &msg;
%end;
%mend;


%let pid = 0;
%let nameValue=type=(test) coverage=(filtering, transports);
%let rc = 0;
%let pid = 0;
%let description=main results package;
%syscall package_begin(pid,description, nameValue, rc);
%chkrc(Package Begin);


%let gifpid=0;
%let description=Gif nested package. ;
%let nameValue=;
%syscall package_begin(gifpid, description, nameValue, rc);
%chkrc(Package Begin);


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;

%let nameValue=;
%let description= B, testing dataset;
%let libname = WORK;
%let memname= B;
%syscall insert_dataset(pid,libname , memname, description, nameValue, rc);
%chkrc(Insert Dataset);


data emp;
input fname $ lname $ ages state $ siblings;
cards;
Steph Jones 32 NC 4
Richard Long  40  NC 2
Mary Robins  74 NC 1
Kai Mack 3   NC 1
Dakota Wills 1 NC 1
Paul Thomas 79 NC 8
Digger Johnson 5  NC 0
Coby Gregson 1   NC 0
Julie Thomson 6 NC 1
Amy Billins 3   NC 1
Brian Gere 16 HA 1
Richard Carter 17 HA 1
Diane Ford 48 CO 4
Pamela Aarons 42 HA 4
Joe Ashford  44 WA 10
Michael Clark 23 IL 1
Michael Harris 31 NM 4
Ken Porter 28 NC 1
Brian Harrison 27 NC 1
Laurie Smith 32 NC 1
Kevin Black 33 NC 1
Steve Jackson 33 NC 1
run;
quit;


%let nameValue= type=report, topic=census;
%let description=North Carolina residents.;
%let libname = WORK;
%let memname= EMP;
%syscall insert_dataset(pid, libname, memname, description, nameValue, rc);
%chkrc(Insert Dataset);


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


%let body=fileref:b;
%let frame=fileref:f;
%let contents=fileref:c;
%let pages=fileref:p;
%let description=Generated ODS output.;
%let curl="contents.html";
%let burl = "body.html";
%let furl = "frame.html";
%let purl = "page.html";
%syscall insert_html(pid, body, burl, frame, frameurl, contents, curl, pages, 
                     purl, description, nameValue, rc);
%chkrc(Insert Html);


/* insert nested package */
%syscall insert_package(pid, gifpid,rc);
%chkrc(Insert Package);


%let giffile=filename:Boeing747.gif;
%let description=New 747 paint scheme.;
%let filetype = text;
%let mimetype = %quote(Image/gif);
%syscall insert_file(gifpid, giffile, filetype, mimetype, description, 
                     nameValue, rc);
%chkrc(Insert File);


/* publish to the FilterTest channel defined in LDAP directory */
%let ldapinfo = "LDAP://alpair01:8010/o=Alpine Airways,c=US";
%let channel1= FilterTest;
%let properties=Subject,Channel_Store;
%let subject=Filter Testing Results;
%let pubType =  to_subscribers;
%syscall package_publish(pid, pubType, rc, properties, subject, ldapinfo, 
                         channel1);
%chkrc(publish package);


/* publish one queue */
%let property=;
%let pubType =  to_queue;
%let queueName=mqseries://JSMITH:LOCAL;
%syscall package_publish(pid, pubType, rc, property, queueName);
%chkrc(publish package);


%syscall package_end(pid,rc);
%chkrc(Package End);


run;
quit;

Contents Publish Package Interface Previous Next