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);
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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