Desktop productivity for business analysts and programmers

Add pop up help text when user defined macros are invoked

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 18
Accepted Solution

Add pop up help text when user defined macros are invoked

[ Edited ]

Hi,

I'm using EG 5.1  .

 

I've written a few macros, each with several parameters. Now, when I calll the macros from different programs I find I don't verbatim remember the parameters for each macro and their position.

 

I noticed that in the program where I created the macros, I could insert comments which appear as pop-up help text when the macro is invoked. But outside that particular program that help does not appear. E.g in below macro the text "libname without quotes e.g. source" appears as a pop-up when the macro is invoked, BUT only in the same program where the macro is written. If I invoke it from a different program in the same project, then no pop-up appears.

 

%macro dir (libname /*libname without quotes e.g. source*/);
	TITLE 'Directory listing for library ' %upcase("&libname") ;

	PROC SQL;
		select libname ,
			memname,
			memlabel,
			nobs,
			nvar,
			modate

		FROM DICTIONARY.TABLES
			WHERE LIBNAME = %upcase( "&libname" ) 
				ORDER BY modate desc;
	QUIT
	;
	TITLE;
%mend dir;


 

Any ideas apprecited.


Accepted Solutions
Solution
‎11-23-2017 07:58 AM
Occasional Contributor
Posts: 18

Re: Add pop up help text when user defined macros are invoked

[ Edited ]

RW9,

 

Thank you very much for the helpful inputs. Valuable.

 

Your idea on Base SAS Abbreviations pointed me to exactly what I'm looking for.

 

In SAS EG 5.1  I found there's a feature Program > Add Abbrevation Macro that fully resolves my issue.  And Program > Editor Macros is very handy to list out all macros put under Add Abbreviation Macro

 

Thanks.

View solution in original post


All Replies
Super User
Super User
Posts: 9,200

Re: Add pop up help text when user defined macros are invoked

Well, first off, this is where named parameters should really be used.  Named parameters such as:

%macro temp (in_file=,out_file=);

Then have some descriptive to tell you what they are, and positioning on the call does not matter as you could call the above:

%temp (in_file=abc,out_file=def);

Or

%temp (out_file=def,in_file=abc);

 Next off, its really not a good idea to use SAS reserved words, like libname, as parameters (or macro variables, or variable names, or anything else).  Just look at the color of your code, it recognises that as a reserved keyword.

 

Next, try using some sort of consistent casing in the code, it will make it far more readable.

 

And you can use Base SAS functions to reduce code, for instance:

%macro dir (lib=);

  title "Directory listing for Library: %upcase(&lib.)";

  proc print data=sashelp.vtables;
    var libname memlabel nobs nvar modate;
    where libname=upcase("&lib.");
  run;

%mend dir;

Also, if your writing a generalised macro, then you would have a user guide, some sort of testing document etc. so the user could refer to these for help?

 

And finally, you can setup in Base SAS Abbreviations which can pre-populate text for you - although I really don't find those helpful.  I am afraid an editor such as Visual Studio where code completion tips pop up is not in SAS releases (at least the ones I have used).  

Solution
‎11-23-2017 07:58 AM
Occasional Contributor
Posts: 18

Re: Add pop up help text when user defined macros are invoked

[ Edited ]

RW9,

 

Thank you very much for the helpful inputs. Valuable.

 

Your idea on Base SAS Abbreviations pointed me to exactly what I'm looking for.

 

In SAS EG 5.1  I found there's a feature Program > Add Abbrevation Macro that fully resolves my issue.  And Program > Editor Macros is very handy to list out all macros put under Add Abbreviation Macro

 

Thanks.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 202 views
  • 0 likes
  • 2 in conversation