Desktop productivity for business analysts and programmers

SAS publish message with attachemnt to a channel

Frequent Contributor
Posts: 82

SAS publish message with attachemnt to a channel

I am trying to use a SAS channel to publish a message with an xls attachment. Once published, users subscribed to that channel will get an email with the attachment. I am not able to find the sample code to do it. Can anyone please help me here?

Community Manager
Posts: 2,691

Re: SAS publish message with attachemnt to a channel

If you're using EG, you can select File->Publish and let the UI lead you through the process.  This will generate a SAS program that you can then use for your purposes.  Here's a sample.

* If this code is executed outside of Enterprise Guide, then metadata logon options must be supplied.
* options metauser="<userID>";

* options metapass="<password>";
* options metaserver=localhost;
* options metaport=8561;


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

/* package preamble */
%let package_options = ABSTRACT;
%let pid = 0;
%let rc = 0;
%let namevalue= ;
%let abstract_text= %nrbquote(Name the publisher here);
%let description = %nrbquote(Publisher);
%syscall package_begin(pid, description, namevalue, rc, package_options, abstract_text);
%chkrc(Package Begin);

/* Add the SAS dataset */
%let namevalue = ;
%let description = %nrbquote(SASHELP.AIR [SAS Data Set]);
%let ttype  = CSV;
%let libname = %nrbquote(SASHELP);
%let memname = %nrbquote(AIR);
%syscall insert_dataset(pid,libname,memname,description,namevalue,rc,prop,ttype);
%chkrc(Insert Dataset);

/* Publish the package */
%let pubType = TO_SUBSCRIBERS;
%let pub_properties = ARCHIVE_PATH, FOLDER_PATH;
%let channel = %nrbquote(Test);
%let folder_path = %nrbquote(/Channels/);
%let archpath = %nrbquote();
%syscall package_publish(pid, pubType, rc, pub_properties, archpath, folder_path, channel);
%chkrc(package publish);
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation