BookmarkSubscribeRSS Feed

Avoiding Warnings for User-Written Functions

Started ‎07-17-2019 by
Modified ‎07-17-2019 by
Views 1,979

If you have ever re-run the creation of a user-written function (proc ), you get a warning.

If you try to delete a user-written function that doesn't exist, you get a warning.

So, I came up with this macro that deletes the function if it exists in work.myfuncs.

 

 

 

%macro delete_function(function);

	%if %sysfunc(exist(WORK.MYFUNCS)) %then %do;

		PROC SQL noprint;
		   SELECT distinct _Key_ into :key
			  FROM WORK.MYFUNCS
			  WHERE _Key_ = "F.DATES.&function";

		%if &sqlobs = 0 %then %return;

		   delete FROM WORK.MYFUNCS
			  WHERE _Key_ = "F.DATES.&function";

		QUIT;

	%end;

%mend delete_function;

 

Version history
Last update:
‎07-17-2019 08:42 AM
Updated by:
Contributors

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags