Hello - hope everyone is ok.
I am running the code below and kept getting the 'ERROR' email. I've checked the previous data steps and found no errors. Does anybody have an idea what I am missing? Thanks a lot!
%if &syscc=0 %then %do;
proc export data=ReportData
dbms=xlsx
replace
outfile='\\drive\Daily_Reporting\Report Name';
sheet='Data';
run;
filename mymail email 'jsmith@email.com'
from='jsmith@email.com'
subject='Report Name'
attach=("\\drive\Daily_Reporting\Report Name'" content_type="appication/xlsx");
data _null_;
file mymail
to=(
'lsmith@email.com'
)
cc=('jsmith@email.com');
run;
%end;
%else %do;
filename mymail email 'jsmith@email.com'
from='jsmith@email.com'
subject='Report Name';
data _null_;
file mymail
to=('jsmith@email.com');
put "ERROR :(";
run;
%end;
What exactly is the value of &syscc ? If it is not 0 then the code shown behaves as intended.
From the documentation:
Contains the current condition code that SAS returns to your operating environment (the operating environment condition code).
So likely you are checking the wrong variable as this is intended to notify something related to the overall status of a SAS job when completed, which is why you can have code that assigns values.
Perhaps you are looking for the SYSERR automatic variable? You want to check the documentation for that but not all procedures will set the variable.
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.
Ready to level-up your skills? Choose your own adventure.