BookmarkSubscribeRSS Feed
eagles_dare13
Obsidian | Level 7

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?

1 REPLY 1
ChrisHemedinger
Community Manager

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;
*************************************************************

ODS _ALL_ CLOSE;

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

/* 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 prop = TRANSFORMATION_TYPE;
%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);
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1021 views
  • 0 likes
  • 2 in conversation