My requirement is to display the subject line as 'PROD' or 'TEST' in email based on the job name qualifier. i m getting the job name using &SYSJOBID variable. However on checking this in my sas program, the comparison fails. Below is my code:
data eg2;
%let trigtype="&SYSJOBID";
%put trigtype;
%put &trigtype;
%put &trigtype.;
/* trigtype got displayed as "AC11895K" in SASlog*/
%let sub1= " ";
if &SYSJOBID EQ "AC11895K"
THEN do;
%let sub1="PROD";
end;
else do;
%let sub1="TEST";
end;
run;
FILENAME OUTBOX EMAIL
TO= ("XXXXXXXXXX")
SUBJECT=&sub1.
-----
My jobname is AC11895K. But SAS sends mail with subject as 'TEST' since the else loop gets satisfied always. Could someone please help in resolving this issue?
Thanks,
Janet
An interesting mixture of macro and datastep code. You should spend some time reading the SAS 9.2 Macro Language: Reference (http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#titlepage.htm), especially the section "Understanding and Using the Macro Facility".
An untested idea:
data _null_; /* you don't need a dataset */
if "&SysJobId" = "AC11895K" then call symputx("sub1"; "PROD");
else call symputx("sub1", "TEST");
run
FILENAME OUTBOX EMAIL
TO= ("XXXXXXXXXX")
SUBJECT="&sub1."
;
Hi,
or you can write complete macro code...for eg
%macro test;
%let jobid=AC11895K;
%let trigtype="&JOBID";
%let sub1= " ";
%if "&JOBID" EQ "AC11895K"
%THEN %do;
%let sub1="PROD";
%end;
%else %do;
%let sub1="TEST";
%end;
%mend test;
%test;
Thanks,
Shiva
Oh. The reason the ELSE loop is satisfied in your code is that you have used the comparison
if &SYSJOBID EQ "AC11895K"
The macro variable &SYSJOBID does not contain a quoted value; your job ID really is AC11895K, right? So then the comparison fails because AC11895K does not equal "AC11895K"!
The comparison will work with either of the following (and maybe other forms, too):
%if &SYSJOBID = AC11895K (in macro code)
or
if "&SysJobId" = "AC11895K" (in data step code)
I hope this helps.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.