BookmarkSubscribeRSS Feed
Bridget53
Calcite | Level 5

How would you email an attachment that the name is located in field in a SAS datasets and the name of the attachment will be difference from day to day?   Below is the code I try to use but I get an error message.

filename mymail email;

data _null_;

    set logfile.logname;

   

    file mymail

        to=('bridget_nelson@hesc.ny.gov')

            from='SASAdmin@hesc.ny.gov'

        replyto= ('bridget_nelson@hesc.ny.gov>')

        subject='Testing'

        attach = "D:\Scheduled_Tasks\GnS\" || LogfileName;

        strBody = "Testing of getting log file name from dataset.";

        put strBody ;

run;

Here is the error message:

filename mymail email;

data _null_;

     set logfile.logname;

   

     file mymail

         to=('bridget_nelson@hesc.ny.gov')

         from='SASAdmin@hesc.ny.gov'

         replyto= ('bridget_nelson@hesc.ny.gov>')

         subject='Testing'

         attach = "D:\Scheduled_Tasks\GnS\" || LogfileName;

                                     -------------------------    -----------

                                     24                           23

ERROR 24-2: Invalid value for the ATTACH option.

ERROR 23-2: Invalid option name LOGFILENAME.

         strBody = "Testing of getting log file name from dataset.";

         put strBody ;

run;

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.03 seconds

s

2 REPLIES 2
Haikuo
Onyx | Level 15

An easy fix on your current code is to use a Macro variable carrying the file name. Try this:

data _null_;

  set logfile.logname;

call symputx('LogfileName', LogfileName);

/*stop;*/

run;  

data _null_;

  file mymail

  to=('bridget_nelson@hesc.ny.gov')

  from='SASAdmin@hesc.ny.gov'

  replyto= ('bridget_nelson@hesc.ny.gov>')

  subject='Testing'

  attach = "D:\Scheduled_Tasks\GnS\&LogfileName";

  strBody = "Testing of getting log file name from dataset.";

   put strBody ;

run;

Haikuo

Bridget53
Calcite | Level 5

Thank you.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 1665 views
  • 0 likes
  • 2 in conversation