When I create a transformation, the only code I put in Source Code is call to the macro which executes the code. That way whenever the code has gone through unit-testing, all the jobs which use that transformation don't have to be re-deployed.
However when the transformation acquires new options, as one of mine did yesterday, my usual approach has been to:
But now I have dozens of jobs that use the transformation, and I couldn't be bothered sighing. I knew that the majority of the jobs wouldn't need to modified, and would get by on the defaults; however the code needed to be aware of the newly created option names and not fall over if the job didn't create them.
The fix is really quite easy, thanks to %symexist. Does the macro exist? No? Then create it, and set it to the same default as the updated parameter requires.
%if %eval(not %symexist(history_type)) %then %do; %global history_type; %let history_type = %nrquote(H2); /* Default, standard processing */ %end;
The new jobs, with history_type defined via the updated transformation, simply bypass the logic. The old jobs, without it, create history_type and populate it.
I appreciate that it won't always be as simple as this, but it saved me a lot of time. And meant that I could go off for my lunch early.
SAS is headed back 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.
Interested in speaking? Content from our attendees is one of the reasons that makes SAS Innovate such a special event!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.