BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
GN0001
Barite | Level 11
%let email = ('bbbb@abc.com' 'dddd@abc.com' 'fff@abc.com');

filename mailit email;
options nosyntaxcheck;

%macro completeit; %if &syscc > 999 %then %do; data _null_; file mailit to=&email subject="&syscc.sas failed"; put "This is an automated message that "&syscc.sas failed" failed with an error code &syscc.."; put; run; %end; %else %do; data _null_; file mailit to=&email subject="job not completed"; put ; put "&outdirectory."; put "=================="; run; %end;

Program:

An email is created and sent over if the program succeeds. I don't have a log created for this code. This code is not resolved or opened in the log window.

Any help is appreciated!

Thanks,

Blue blue

Blue Blue
1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

A SAS macro must start with a %MACRO statement and end in a %MEND statement. I don't see a %MEND statement in your code. However to call the macro you need to add the statement %COMPLETEIT; as well otherwise it will never get executed.

 

Try this:

%macro completeit;
  %if &syscc > 999 %then %do;
    data _null_;
      file mailit
           to=&email
           subject="&syscc.sas failed";

      put "This is an automated message that "&syscc.sas failed" failed with an error code &syscc..";
      put;
    run;
  %end;

  %else %do;

  data _null_;
     file mailit
          to=&email
           subject="job not completed";
            put ;
            put "&outdirectory.";
			put "==================";
			
    run;

  %end;
%mend;

%completeit;

 

View solution in original post

7 REPLIES 7
SASKiwi
PROC Star

A SAS macro must start with a %MACRO statement and end in a %MEND statement. I don't see a %MEND statement in your code. However to call the macro you need to add the statement %COMPLETEIT; as well otherwise it will never get executed.

 

Try this:

%macro completeit;
  %if &syscc > 999 %then %do;
    data _null_;
      file mailit
           to=&email
           subject="&syscc.sas failed";

      put "This is an automated message that "&syscc.sas failed" failed with an error code &syscc..";
      put;
    run;
  %end;

  %else %do;

  data _null_;
     file mailit
          to=&email
           subject="job not completed";
            put ;
            put "&outdirectory.";
			put "==================";
			
    run;

  %end;
%mend;

%completeit;

 

GN0001
Barite | Level 11

Hello SASKIWI,

 

Wow, it is resolved! Thank you so very much. I needed to deliver the results of the program to leaders.

 

Thanks,

 

Bita

Blue Blue
GN0001
Barite | Level 11

Hello team,

After a month, I came to run this code that mentioned on the start of this forum, it fails with error code 3000. While the program run correct, but the email message is created is a fail.

SYMBOLGEN:  Macro variable SYSCC resolves to 3000

I can't send the rest of the log, because it is confidential.

Regards,

blue

Blue Blue
GN0001
Barite | Level 11

hello team,

I ran into same issue after a month.

I get &syscc to 3000.

I run the program line by line and no error in the log but as soon as I go to the part which I marked as answer, it gives me error code 3000.

regards,

a blue

Blue Blue
ballardw
Super User

If the code was working correctly and the code was not changed then something else has changed. Possibly email addresses??? or stuff sent to the email system.

 

I might ask about changes to your system done by IT for any of the involved programs such as email.

 

If the code was changed, then you get start all over with the debug cycle.

Kurt_Bremser
Super User

Anything except zero is unnacceptable for SYSCC at the end of a job.

Any non-zero value means (at least) one of:

  • an ERROR has occured
  • a WARNING has occured
  • SYSCC was explicitly set (%LET, CALL SYMPUT, SELECT INTO)

You need to work through your whole log from top to bottom to fix any occurence of the above. If in doubt, add

%put &=syscc.;

frequently in your code to detect the location where something goes wrong (if it's not an obvious ERROR or WARNING).

GN0001
Barite | Level 11

Thanks,

I had a backup of the program so I used that one and I never realized what is the difference one works and one doesn’t work. 
respectfully,

blue thunder 

Blue Blue

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 1487 views
  • 3 likes
  • 4 in conversation