BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Max-A
Obsidian | Level 7
1                                                          The SAS System                           11:33 Thursday, November 1, 2018

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program_newMaill';
4          %LET _CLIENTPROJECTPATH='R:\Mijn Documenten\Stagedocumenten\Eigen project\Prototypes\AutoTest_new.egp';
5          %LET _CLIENTPROJECTNAME='AutoTest_new.egp';
6          %LET _SASPROGRAMFILE=;
7          
8          ODS _ALL_ CLOSE;
9          OPTIONS DEV=ACTIVEX;
10         GOPTIONS XPIXELS=0 YPIXELS=0;
11         FILENAME EGSR TEMP;
12         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR STYLE=HtmlBlue
12       ! STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/x86/SASEnterpriseGuide/5.1/Styles/HtmlBlue.css") NOGTITLE NOGFOOTNOTE
12       !  GPATH=&sasworklocation ENCODING=UTF8 options(rolap="on");
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
13         
14         GOPTIONS ACCESSIBLE;
15         data _null_;
16         if &testMacro = 1 then call execute('%mail');
17         run;

MPRINT(MAIL):   FILENAME Mailbox EMAIL "" type="text/html" subject="Automatische controle";
"why isnt it working"
MPRINT(MAIL):   * data _null_;
MPRINT(MAIL):   file Mailbox;
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

NOTE: CALL EXECUTE generated line.
1         + FILENAME Mailbox EMAIL ""  type="text/html" subject="Automatische controle"; *  data _null_; file 
Mailbox;
NOTE: Line generated by the CALL EXECUTE routine.
1         + FILENAME Mailbox EMAIL ""  type="text/html" subject="Automatische controle"; *  data _null_; file
                                                                                                                             ____
                                                                                                                             180
1        !+Mailbox;
ERROR 180-322: Statement is not valid or it is used out of proper order.

18         
19         
20         GOPTIONS NOACCESSIBLE;
21         %LET _CLIENTTASKLABEL=;
22         %LET _CLIENTPROJECTPATH=;
23         %LET _CLIENTPROJECTNAME=;
24         %LET _SASPROGRAMFILE=;
25         
26         ;*';*";*/;quit;run;
27         ODS _ALL_ CLOSE;
28         
29         
30         QUIT; RUN;
31         

The error still remains, i just don't get what is wrong . I tried %file Mailbox. But that is not the solution either

 

proc sql;
select case when nmiss(name)=0 and nmiss(age)=0 and nmiss(sex)=0 then 1
	else 0 end into:testMacro
	from work.test;
quit;


%macro mail;
FILENAME Mailbox EMAIL "" 
type="text/html"
subject="Automatische controle";
%put "why isnt it working";

data _null_;
file Mailbox;
%if &testMacro = 0
%then %do;
	%put "values in mailcond are > 0";
%end;
%run;
%mend mail;

data _null_;
if &testMacro = 1 then call execute('%mail');
run;
SuryaKiran
Meteorite | Level 14

Remove '%' symbol before RUN. It has to be just 'run' not '%run'

 

Please find my comments below:

proc sql;
select case when nmiss(name)=0 and nmiss(age)=0 and nmiss(sex)=0 then 1
	else 0 end into:testMacro
	from work.test;
quit;


%macro mail;
FILENAME Mailbox EMAIL 
to="test@email.com" /* TO= is missing */
type="text/html"
subject="Automatische controle";
%put "why isnt it working";

data _null_;
file Mailbox;
/* You maynot need the 'if' condition anymore */
/*%if &testMacro = 0*/
/*%then %do;*/
/*	%put "values in mailcond are > 0";*/
/*%end;*/
run;
%mend mail;

data _null_;
if &testMacro = 0 then call execute('%mail');
run;
Thanks,
Suryakiran
Kurt_Bremser
Super User

When you call execute a macro that contains macro logic, use %nrstr:

call execute('%nrstr(%mail'));

otherwise you will experience macro timing problems. Macro statements are executed immediately, but Base SAS code has to wait until the calling datastep ends. %nrstr prevents premature execution of macro logic.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 17 replies
  • 1320 views
  • 5 likes
  • 3 in conversation