I am trying to collect the status of meta server by proc metaoperate to each server( server is to be fetched using macro).
The attached code seems to run without even running proc metaoperate part. Could you please help me in resolving the issue.
298 libname final "C:\Users\ghospiya\OneDrive - Merck Sharp & Dohme LLC\Documents\Status_jobs";
NOTE: Libref FINAL was successfully assigned as follows:
Engine: V9
Physical Name: C:\Users\ghospiya\OneDrive - Merck Sharp & Dohme LLC\Documents\Status_jobs
299 DATA WORK.TEST;
300 LENGTH
301 Server $ 11 ;
302 FORMAT
303 Server $CHAR11. ;
304 INFORMAT
305 Server $CHAR11. ;
306 INFILE 'C:\Users\ghospiya\OneDrive - Merck Sharp & Dohme
306! LLC\Documents\Status_jobs\test1.txt'
307 LRECL=32767
308 ENCODING="WLATIN1"
309 DLM='2c'x
310 MISSOVER
311 DSD ;
312 INPUT
313 Server : $CHAR11. ;
314 RUN;
NOTE: The infile 'C:\Users\ghospiya\OneDrive - Merck Sharp & Dohme
LLC\Documents\Status_jobs\test1.txt' is:
Filename=C:\Users\ghospiya\OneDrive - Merck Sharp & Dohme LLC\Documents\Status_jobs\test1.txt,
RECFM=V,LRECL=32767,File Size (bytes)=36,
Last Modified=22Jan2025:13:27:47,
Create Time=13Jan2025:13:01:26
NOTE: 3 records were read from the infile 'C:\Users\ghospiya\OneDrive - Merck Sharp & Dohme
LLC\Documents\Status_jobs\test1.txt'.
The minimum record length was 10.
The maximum record length was 10.
NOTE: The data set WORK.TEST has 3 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
315 OPTIONS MPRINT MLOGIC SYMBOLGEN;
316
317
318 %macro Do_stuff(input_var);
319 %let srv1 = %str(%'&input_var.%');
320 %macro meta_server ( serv,srv );
321 %put &serv;
322 %put &srv;
323 PROC METAOPERATE
324 SERVER=&srv
325 PORT=8561
326 USERID='sasadm@saspw'
327 PASSWORD='xxxx'
328 PROTOCOL=BRIDGE
329 ACTION=STATUS
330 out=metaout;
331 RUN;
332
333 /*%macro check_exists(data);
334 %if %sysfunc(exist(&data.)) %then %do;
335 %put Dataset Exists;*/
336
337 data work.metaout_t;
338 set work.metaout;
339 keep attribute value;
340 where attribute in ('Server','Query Time','Status');
341 run;
342
343 proc sql;
344 select value into :a from metaout_t where attribute='Server' ;
345 quit;
346
347 proc transpose data=work.metaout_t out=metastat_&a(rename=(col1=server col2=date col3=status)
347! drop=_name_);
348 var value;
349 run;
350
351 /* %end;
352 %else %do;
353 %put Dataset Does Not Exist;
354 data metaout_t_&serv;
355 server=symget('serv');
356 date= "&sysdate"d;
357 format run_date date9.;
358 status= 'Not Running';
359 run;
360 %end;
361 %mend check_exists;
362 %check_exists(metaout); */
363
364 proc append data=metastat_&serv base=final.metastat_out force;run;
365
366 %mend meta_server;
367 %meta_server ( &input_var, &srv1 );
368 %mend do_stuff;
369
370 data _null_;
371 set WORK.TEST;
372 rc=dosubl('%do_stuff('||Server||')' );
373 run;
MLOGIC(DO_STUFF): Beginning execution.
MLOGIC(DO_STUFF): Parameter INPUT_VAR has value lctcvt7962
MLOGIC(DO_STUFF): %LET (variable name is SRV1)
SYMBOLGEN: Macro variable INPUT_VAR resolves to lctcvt7962
MLOGIC(META_SERVER): Beginning execution.
SYMBOLGEN: Macro variable INPUT_VAR resolves to lctcvt7962
SYMBOLGEN: Macro variable SRV1 resolves to 'lctcvt7962'
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
MLOGIC(META_SERVER): Parameter SERV has value lctcvt7962
MLOGIC(META_SERVER): Parameter SRV has value lctcvt7962
MLOGIC(META_SERVER): %PUT &serv
SYMBOLGEN: Macro variable SERV resolves to lctcvt7962
lctcvt7962
MLOGIC(META_SERVER): %PUT &srv
SYMBOLGEN: Macro variable SRV resolves to 'lctcvt7962'
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
'lctcvt7962'
ERROR 22-322: Expecting a quoted string.
ERROR 200-322: The symbol is not recognized and will be ignored.
SYMBOLGEN: Macro variable SRV resolves to 'lctcvt7962'
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
MPRINT(META_SERVER): PROC METAOPERATE SERVER='lctcvt7962' PORT=8561 USERID='sasadm@saspw'
PASSWORD='xxxx' PROTOCOL=BRIDGE ACTION=STATUS out=metaout;
MPRINT(META_SERVER): RUN;
WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.METAOUT may be incomplete. When this step was stopped there were 0
observations and 0 variables.
WARNING: Data set WORK.METAOUT was not replaced because this step was stopped.
NOTE: PROCEDURE METAOPERATE used (Total process time):
real time 0.00 seconds
cpu time 0.03 seconds
MPRINT(META_SERVER): data work.metaout_t;
MPRINT(META_SERVER): set work.metaout;
MPRINT(META_SERVER): keep attribute value;
MPRINT(META_SERVER): where attribute in ('Server','Query Time','Status');
ERROR: Variable attribute is not on file WORK.METAOUT.
MPRINT(META_SERVER): run;
WARNING: The variable attribute in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable value in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.METAOUT_T may be incomplete. When this step was stopped there were 0
observations and 0 variables.
WARNING: Data set WORK.METAOUT_T was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
MPRINT(META_SERVER): proc sql;
MPRINT(META_SERVER): select value into :a from metaout_t where attribute='Server' ;
ERROR: Table WORK.METAOUT_T doesn't have any columns. PROC SQL requires each of its tables to have
at least 1 column.
ERROR: The following columns were not found in the contributing tables: attribute, value.
MPRINT(META_SERVER): quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATA, DELIM, DELIMITER, INDB,
LABEL, LET, NAME, OUT, PREFIX, SUFFIX.
ERROR 76-322: Syntax error, statement will be ignored.
WARNING: Apparent symbolic reference A not resolved.
WARNING: Apparent symbolic reference A not resolved.
MPRINT(META_SERVER): proc transpose data=work.metaout_t out=metastat_&a(rename=(col1=server
col2=date col3=status) drop=_name_);
MPRINT(META_SERVER): var value;
MPRINT(META_SERVER): run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
SYMBOLGEN: Macro variable SERV resolves to lctcvt7962
ERROR: File WORK.METASTAT_LCTCVT7962.DATA does not exist.
MPRINT(META_SERVER): proc append data=metastat_lctcvt7962 base=final.metastat_out force;
MPRINT(META_SERVER): run;
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: The SAS System stopped processing this step because of errors.
MLOGIC(META_SERVER): Ending execution.
MPRINT(DO_STUFF): ;
MLOGIC(DO_STUFF): Ending execution.
MLOGIC(DO_STUFF): Beginning execution.
MLOGIC(DO_STUFF): Parameter INPUT_VAR has value lctcvt7982
MLOGIC(DO_STUFF): %LET (variable name is SRV1)
SYMBOLGEN: Macro variable INPUT_VAR resolves to lctcvt7982
MLOGIC(META_SERVER): Beginning execution.
SYMBOLGEN: Macro variable INPUT_VAR resolves to lctcvt7982
SYMBOLGEN: Macro variable SRV1 resolves to 'lctcvt7982'
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
MLOGIC(META_SERVER): Parameter SERV has value lctcvt7982
MLOGIC(META_SERVER): Parameter SRV has value lctcvt7982
MLOGIC(META_SERVER): %PUT &serv
SYMBOLGEN: Macro variable SERV resolves to lctcvt7982
lctcvt7982
MLOGIC(META_SERVER): %PUT &srv
SYMBOLGEN: Macro variable SRV resolves to 'lctcvt7982'
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
'lctcvt7982'
ERROR 22-322: Expecting a quoted string.
ERROR 200-322: The symbol is not recognized and will be ignored.
SYMBOLGEN: Macro variable SRV resolves to 'lctcvt7982'
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
MPRINT(META_SERVER): PROC METAOPERATE SERVER='lctcvt7982' PORT=8561 USERID='sasadm@saspw'
PASSWORD='xxxx' PROTOCOL=BRIDGE ACTION=STATUS out=metaout;
MPRINT(META_SERVER): RUN;
WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.METAOUT may be incomplete. When this step was stopped there were 0
observations and 0 variables.
WARNING: Data set WORK.METAOUT was not replaced because this step was stopped.
NOTE: PROCEDURE METAOPERATE used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
MPRINT(META_SERVER): data work.metaout_t;
MPRINT(META_SERVER): set work.metaout;
MPRINT(META_SERVER): keep attribute value;
MPRINT(META_SERVER): where attribute in ('Server','Query Time','Status');
ERROR: Variable attribute is not on file WORK.METAOUT.
MPRINT(META_SERVER): run;
WARNING: The variable attribute in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable value in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.METAOUT_T may be incomplete. When this step was stopped there were 0
observations and 0 variables.
WARNING: Data set WORK.METAOUT_T was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
MPRINT(META_SERVER): proc sql;
MPRINT(META_SERVER): select value into :a from metaout_t where attribute='Server' ;
ERROR: Table WORK.METAOUT_T doesn't have any columns. PROC SQL requires each of its tables to have
at least 1 column.
ERROR: The following columns were not found in the contributing tables: attribute, value.
MPRINT(META_SERVER): quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATA, DELIM, DELIMITER, INDB,
LABEL, LET, NAME, OUT, PREFIX, SUFFIX.
ERROR 76-322: Syntax error, statement will be ignored.
WARNING: Apparent symbolic reference A not resolved.
WARNING: Apparent symbolic reference A not resolved.
MPRINT(META_SERVER): proc transpose data=work.metaout_t out=metastat_&a(rename=(col1=server
col2=date col3=status) drop=_name_);
MPRINT(META_SERVER): var value;
MPRINT(META_SERVER): run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
SYMBOLGEN: Macro variable SERV resolves to lctcvt7982
ERROR: File WORK.METASTAT_LCTCVT7982.DATA does not exist.
MPRINT(META_SERVER): proc append data=metastat_lctcvt7982 base=final.metastat_out force;
MPRINT(META_SERVER): run;
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: The SAS System stopped processing this step because of errors.
MLOGIC(META_SERVER): Ending execution.
MPRINT(DO_STUFF): ;
MLOGIC(DO_STUFF): Ending execution.
MLOGIC(DO_STUFF): Beginning execution.
MLOGIC(DO_STUFF): Parameter INPUT_VAR has value lctcvt7983
MLOGIC(DO_STUFF): %LET (variable name is SRV1)
SYMBOLGEN: Macro variable INPUT_VAR resolves to lctcvt7983
MLOGIC(META_SERVER): Beginning execution.
SYMBOLGEN: Macro variable INPUT_VAR resolves to lctcvt7983
SYMBOLGEN: Macro variable SRV1 resolves to 'lctcvt7983'
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
MLOGIC(META_SERVER): Parameter SERV has value lctcvt7983
MLOGIC(META_SERVER): Parameter SRV has value lctcvt7983
MLOGIC(META_SERVER): %PUT &serv
SYMBOLGEN: Macro variable SERV resolves to lctcvt7983
lctcvt7983
MLOGIC(META_SERVER): %PUT &srv
SYMBOLGEN: Macro variable SRV resolves to 'lctcvt7983'
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
'lctcvt7983'
ERROR 22-322: Expecting a quoted string.
ERROR 200-322: The symbol is not recognized and will be ignored.
SYMBOLGEN: Macro variable SRV resolves to 'lctcvt7983'
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been
unquoted for printing.
MPRINT(META_SERVER): PROC METAOPERATE SERVER='lctcvt7983' PORT=8561 USERID='sasadm@saspw'
PASSWORD='xxxx' PROTOCOL=BRIDGE ACTION=STATUS out=metaout;
MPRINT(META_SERVER): RUN;
WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.METAOUT may be incomplete. When this step was stopped there were 0
observations and 0 variables.
WARNING: Data set WORK.METAOUT was not replaced because this step was stopped.
NOTE: PROCEDURE METAOPERATE used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
MPRINT(META_SERVER): data work.metaout_t;
MPRINT(META_SERVER): set work.metaout;
MPRINT(META_SERVER): keep attribute value;
MPRINT(META_SERVER): where attribute in ('Server','Query Time','Status');
ERROR: Variable attribute is not on file WORK.METAOUT.
MPRINT(META_SERVER): run;
WARNING: The variable attribute in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable value in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.METAOUT_T may be incomplete. When this step was stopped there were 0
observations and 0 variables.
WARNING: Data set WORK.METAOUT_T was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
MPRINT(META_SERVER): proc sql;
MPRINT(META_SERVER): select value into :a from metaout_t where attribute='Server' ;
ERROR: Table WORK.METAOUT_T doesn't have any columns. PROC SQL requires each of its tables to have
at least 1 column.
ERROR: The following columns were not found in the contributing tables: attribute, value.
MPRINT(META_SERVER): quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATA, DELIM, DELIMITER, INDB,
LABEL, LET, NAME, OUT, PREFIX, SUFFIX.
ERROR 76-322: Syntax error, statement will be ignored.
WARNING: Apparent symbolic reference A not resolved.
WARNING: Apparent symbolic reference A not resolved.
MPRINT(META_SERVER): proc transpose data=work.metaout_t out=metastat_&a(rename=(col1=server
col2=date col3=status) drop=_name_);
MPRINT(META_SERVER): var value;
MPRINT(META_SERVER): run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
SYMBOLGEN: Macro variable SERV resolves to lctcvt7983
ERROR: File WORK.METASTAT_LCTCVT7983.DATA does not exist.
MPRINT(META_SERVER): proc append data=metastat_lctcvt7983 base=final.metastat_out force;
MPRINT(META_SERVER): run;
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
NOTE: The SAS System stopped processing this step because of errors.
MLOGIC(META_SERVER): Ending execution.
MPRINT(DO_STUFF): ;
MLOGIC(DO_STUFF): Ending execution.
NOTE: There were 3 observations read from the data set WORK.TEST.
NOTE: DATA statement used (Total process time):
real time 1.11 seconds
cpu time 0.57 seconds
374
375 options mprint;
376
377 data x ;set final.metastat_out;
378 rundate= input(date,date9.);
379 format rundate date9.;
380 drop date;
381 run;
NOTE: There were 0 observations read from the data set FINAL.METASTAT_OUT.
NOTE: The data set WORK.X has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
382
383 proc sort data=x out=x nodupkey;
384 by server rundate;
385 run;
NOTE: Input data set is empty.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.X has 0 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
386
387
388 ods listing close;
389 ods html body='metadata_status.htm'
390 style=statistical;
NOTE: Writing HTML Body file: metadata_status.htm
391
392 proc print data=x noobs;
393 where rundate eq ("&sysdate"d);
SYMBOLGEN: Macro variable SYSDATE resolves to 22JAN25
394 run;
NOTE: No observations in data set WORK.X.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
395
396 ods html close;
I suspect you are having trouble defining your macro variables which is leading to the invalid code generation by your macros. But it is extremely hard to follow your SAS log because of the following things.
Mainly because you pasted into the body of you message so it got reflowed as paragraphs and printed with proportional font.
Also you seem to have placed one macro definition inside of another. That is just going to confuse the humans that have to try and understand the code. Unlike macro variables that can live in local symbol tables the address space for macros is flat. So define each macro independently. This will make the code easier to follow and make it clearer which macro variable should be local to which macro.
Finally your use of DOSUBL to try and run "side" sessions of SAS code. You could make your flow simpler by just having the data step write the macro calls to a text file and then use %INCLUDE to run the generated code after the data step has finished. That will make the process flow be more linear and easier to debug.
i have tried to make it simpler now by segregating this into 2 codes. but by doing that, i could see, the program fails to run. I can understand that the code could run for one macro variable but fails to run for others. Could you please help.
Once you get this ERROR the rest of the steps cannot work since the dataset it was supposed to produce is not there.
MPRINT(META_SERVER): RUN;
ERROR: IOM call failed.
NOTE: PROCEDURE METAOPERATE used (Total process time):
Can you run that step of the code without all of the code generation? If not then the macro code is generating the wrong SAS code somehow.
I still do not see how DOSUBL() is doing you anything in this code. Replace it with CALL EXECUTE().
I have changed the code entirely and could generate a html report as attached here. Now i want to send this html report to users but not able to do so.
I have tried the below code but it is generating an email with lots of dummy character.
/* Read the HTML report into a macro variable */
filename mymail email
to='ghospiya@merck.com'
subject='Status Report'
type='text/html';
data _null_;
file mymail;
infile "C:\Users\ghospiya\Documents\report.html" lrecl=32767 end=eof;;
input;
put _infile_;
run;
filename mymail clear;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.