BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Muyu
Calcite | Level 5

Hi there,

 

Can anyone give me a brief explaination of the parameter "server" and "title" in the following code? I want to know what they are and what they do.

 

%macro sas_title(
server = NO,
macro = ,
title = ,
step = ,
msg1 = ,
msg2 = ,
msg3 = ,
msg4 = ,
msg5 = ,
msg6 = ,
msg7 = ,
msg8 = ,
msg9 =
);

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

So it writes NOTES to the SAS log using the %PUT macro statement. The meaning of most of the parameters seems pretty obvious. I see only two tricky things here.

1) is the reference to the undefined macro variable MACRO.  I assume thta this macro is used in an environment where that macro variable is defined before this macro is called.

2) It will conditionally run the code in the a remote SAS/Connect session instead of the local SAS session where it is originally submitted. I checks the parameter SERVER to know which remote session to run on.  But it will only remote submit if the local session is running on a windows machine.

View solution in original post

7 REPLIES 7
Tom
Super User Tom
Super User

To understand what a macro does you need to read the code.  If you are lucky the author has provided comments that will help.

Muyu
Calcite | Level 5

The Entire Macro is shown below. I just cannot understand it...

 

/*========================================================================================*/
/* */
/* macro: sas_title */
/* */
/* -------------------------------------------------------------------------------------- */
/* */
/* notes: 1. This sas macro is designed to display a sas title box to */
/* the sas log. */
/* */
/* 2. This sas macro may display the following parameters: */
/* */
/* 3. By default the routine display the date and time only. */
/* */
/* parms: 1. macro = a macro name specified by the user. */
/* 2. step = a step number specified by the user. */
/* 3. msg1 = a customer message. */
/* 4. msg2 = a customer message. */
/* 5. msg3 = a customer message. */
/* 6. msg4 = a customer message. */
/* 7. msg5 = a customer message. */
/* 8. msg6 = a customer message. */
/* 9. msg7 = a customer message. */
/* 10. msg8 = a customer message. */
/* 11. msg9 = a customer message. */
/* */
/*========================================================================================*/
%macro sas_title(
server = NO,
macro = ,
title = ,
step = ,
msg1 = ,
msg2 = ,
msg3 = ,
msg4 = ,
msg5 = ,
msg6 = ,
msg7 = ,
msg8 = ,
msg9 =
);

 

/*========================================================================================*/
/* */
/* step 00010 Convert server switch to upper case ( YES/NO ) */
/* */
/*========================================================================================*/

%let server = %upcase(&server.);


/*========================================================================================*/
/* */
/* step 00020 Create display date and time */
/* */
/*========================================================================================*/

%let display_date = %sysfunc( date(), weekdate. );

%let display_time = %sysfunc( time(), time.);


/*========================================================================================*/
/* */
/* step 00030 Send sas macro parms to sas server. */
/* */
/*========================================================================================*/

%if &sysscp. = WIN
and &server. = YES %then %do;

%syslput server = &server.;
%syslput title = &title.;
%syslput msg1 = &msg1.;
%syslput msg2 = &msg2.;
%syslput msg3 = &msg3.;
%syslput msg4 = &msg4.;
%syslput msg5 = &msg5.;
%syslput msg6 = &msg6.;
%syslput msg7 = &msg7.;
%syslput msg8 = &msg8.;
%syslput msg9 = &msg9.;

rsubmit;

%end;


/*========================================================================================*/
/* */
/* step 00040 Display the SAS title box to the sas log. */
/* */
/*========================================================================================*/

%put;
%put NOTE: &dline.;
%put NOTE: ;

/*----------------------------------------------------------------------------------------*/
/* step 101 Display the optional SAS Macro Name. */
/*----------------------------------------------------------------------------------------*/

%if %nrbquote(&macro.) ne %str( ) %then %do;

%put NOTE: Macro: &macro.;
%put NOTE: ;
%put NOTE: ;

%end;

/*----------------------------------------------------------------------------------------*/
/* step 102 Display the optional SAS Step Number and title. */
/*----------------------------------------------------------------------------------------*/

%if %nrbquote(&step.) ne %str( )
and %nrbquote(&title.) ne %str( ) %then %do;

%put NOTE: Step: &step. &title.;
%put NOTE: ;
%put NOTE: ;

%end;

%if %nrbquote(&step.) eq %str( )
and %nrbquote(&title.) ne %str( ) %then %do;

%put NOTE: &title.;
%put NOTE: ;
%put NOTE: ;

%end;


/*----------------------------------------------------------------------------------------*/
/* step 103 Display the mandatory Date and Time. */
/*----------------------------------------------------------------------------------------*/

%put NOTE: Date: &display_date.;
%put NOTE: ;
%put NOTE: Time: &display_time.;
%put NOTE: ;

/*----------------------------------------------------------------------------------------*/
/* step 104 Display the optional message number 1. */
/*----------------------------------------------------------------------------------------*/

%if %nrbquote(&msg1.) ne %str( ) %then %do;

%put NOTE: Notes:;
%put NOTE: ;
%put NOTE: 1. &msg1.;
%put NOTE: ;

%end;

/*----------------------------------------------------------------------------------------*/
/* step 105 Display the optional message number 2. */
/*----------------------------------------------------------------------------------------*/

%if %nrbquote(&msg2.) ne %str( ) %then %do;

%put NOTE: 2. &msg2.;
%put NOTE: ;

%end;

/*----------------------------------------------------------------------------------------*/
/* step 106 Display the optional message number 3. */
/*----------------------------------------------------------------------------------------*/

%if %nrbquote(&msg3.) ne %str( ) %then %do;

%put NOTE: 3. &msg3.;
%put NOTE: ;

%end;

/*----------------------------------------------------------------------------------------*/
/* step 107 Display the optional message number 4. */
/*----------------------------------------------------------------------------------------*/

%if %nrbquote(&msg4.) ne %str( ) %then %do;

%put NOTE: 4. &msg4.;
%put NOTE: ;

%end;

/*----------------------------------------------------------------------------------------*/
/* step 108 Display the optional message number 5. */
/*----------------------------------------------------------------------------------------*/

%if %nrbquote(&msg5.) ne %str( ) %then %do;

%put NOTE: 5. &msg5.;
%put NOTE: ;

%end;

/*----------------------------------------------------------------------------------------*/
/* step 109 Display the optional message number 6. */
/*----------------------------------------------------------------------------------------*/

%if %nrbquote(&msg6.) ne %str( ) %then %do;

%put NOTE: 6. &msg6.;
%put NOTE: ;

%end;

/*----------------------------------------------------------------------------------------*/
/* step 110 Display the optional message number 7. */
/*----------------------------------------------------------------------------------------*/

%if %nrbquote(&msg7.) ne %str( ) %then %do;

%put NOTE: 7. &msg7.;
%put NOTE: ;

%end;

/*----------------------------------------------------------------------------------------*/
/* step 111 Display the optional message number 8. */
/*----------------------------------------------------------------------------------------*/

%if %nrbquote(&msg8.) ne %str( ) %then %do;

%put NOTE: 8. &msg8.;
%put NOTE: ;

%end;

/*----------------------------------------------------------------------------------------*/
/* step 112 Display the optional message number 9. */
/*----------------------------------------------------------------------------------------*/
%if %nrbquote(&msg9.) ne %str( ) %then %do;

%put NOTE: 9. &msg9.;
%put NOTE: ;

%end;

/*----------------------------------------------------------------------------------------*/
/* step 113 Display the end of the message box. */
/*----------------------------------------------------------------------------------------*/

%put NOTE: &dline.;
%put;

 

/*========================================================================================*/
/* */
/* step 113 Display the end of the message box. */
/*========================================================================================*/

%if &sysscp. = WIN
and &server. = YES %then %do;

endrsubmit;

%end;

Tom
Super User Tom
Super User

So it writes NOTES to the SAS log using the %PUT macro statement. The meaning of most of the parameters seems pretty obvious. I see only two tricky things here.

1) is the reference to the undefined macro variable MACRO.  I assume thta this macro is used in an environment where that macro variable is defined before this macro is called.

2) It will conditionally run the code in the a remote SAS/Connect session instead of the local SAS session where it is originally submitted. I checks the parameter SERVER to know which remote session to run on.  But it will only remote submit if the local session is running on a windows machine.

Reeza
Super User

Check the macro documentation. 

 

Is this a SAS supplied macro or a user written macro? It appears user written so you would at minimum have to include the macro code for us to guess at what the parameters might be. We can guess that title is a string but server could be a name or a specification string. 

Muyu
Calcite | Level 5
Thank you for replying. I have posted the Macro code above.
Reeza
Super User

Server is YES or NO. 

 

But why why are you using a macro when you don't know what it does? 

Muyu
Calcite | Level 5
Thank you for replying, I have post the entire macro code.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 872 views
  • 0 likes
  • 3 in conversation