Example 3: Example: Publishing with the FTP Access Method

The following example uses the FTP access method to put ODS-generated output onto the server jsmith.pc.alpair.com in the Windows operating environment. Note that the INSERT_REFERENCE CALL routine is used so that only references to the newly created HTML files are inserted into the package. Subscribers using the EMAIL transport engine receive an e-mail message, with an embedded link to the HTML files within it.
filename myfram ftp 'odsftpf.htm'
   host='jsmith.pc.alpair.com'
   user='anonymous'
   pass='smi96Gth';

filename mybody ftp 'odsftpb.htm'
   host='jsmith.pc.alpair.com'
   user='anonymous'
   pass='smi96Gth';

filename mypage ftp 'odsftpp.htm'
   host='jsmith.pc.alpair.com'
   user='anonymous'
   pass='smi96Gth';

filename mycont ftp 'odsftpc.htm'
   host='jsmith.pc.alpair.com'
   user='anonymous'
   pass='smi96Gth';

ods listing close;
ods html frame=myfram body=mybody page=mypage
   contents=mycont;

title 'ODS HTML Generation to PC Files via
   FTP Access Method';
   data retail;
      set alpairhelp.retail;
      decade = floor(year/10) * 10;
      run;

proc format;
   /* maps foreground colors for total sales */
   value salecol
      low-1500 = 'red'
      1500-2000 = 'yellow'
      2000-high = 'green';

   /* gives the row labels some color */
   value decbg
      1980 = '#00aaaa'
      1990 = '#00cccc';

   /* gives the decade flyovers */
   value decfly
      1980 = 'Me Me Me Generation'
      1990 = 'Kinder Gentler Generation';
   run;

proc tabulate data=retail;

   class year decade;
   classlev decade / s={background=decbg.
      flyover=decfly.};
   classlev year / s=<parent>;

   var sales;
   table decade * year ,
      sales *
         ( sum * f=dollar12. *
            {style={foreground=salecol. font_weight=bold}}
         median * f=dollar12. * {style={foreground=black}}
      );
   run;

   data a;
      do j=1 to 5;
      do k=1 to 5;
      do i = 1 to 10;
         x=ranuni(i);
      output;end; end; end;
   run;

   proc sort data=a; by j;
   run;

   proc sort data=a; by j k;
   run;

   proc univariate; by j k; var i;
   run;

   title1;
   quit;

ods html close;

data _null_;
length desc $ 1000;
rc=0;a='a';b='b';c='c';d='d';

packageId = 0;

CALL PACKAGE_BEGIN(packageId,"Weekly Activities Report",
   'Type=Report', rc);
if (rc eq 0) then put 'Package begin successful.';
else do;
   msg = sysmsg();
   put msg;
end;

desc="Retail sales information and miscellaneous
   statistics viewed at :";
nv="";
CALL INSERT_REF(packageId, "HTML",
   "http://jsmith.pc.alpair.com/odsftpf.htm",
      desc, nv, rc);
if rc ne 0 then do;
   msg = sysmsg();
   put msg;
end;
else
   put 'Insert reference ok';

storeinfo =
   "SAS-OMA://alpsrv03.sys.com:8561";
   channel1= 'emailonly';
subject = "Monday's Update";
properties = 'subject, channel_store, metauser, metapass';
user = "myUserName";
password = "myPassword";
CALL PACKAGE_PUBLISH(packageId, "TO_SUBSCRIBERS", rc,
   properties, subject, storeinfo, 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 term successful';

run;
quit;