please help for solution
Let's breakdown the assignment into parts:
macro function %countdown
Sounds like they want to to define a SAS macro named COUNTDOWN. Do you know what statement that is?
It is strange that they used the term FUNCTION here. Are they trying to say that the macro only generates part of statement so that it can be used in the middle of a statement or expression, like you would use an actual SAS function call?
having a numeric parameter
SAS parameters are macro variables (or they become macro variables that local to the macro). And macro variables always contain text. I think they mean here that the macro will expect the parameter values to be text strings that SAS code would interpret as numbers. Like 10.
and producing the following output in the log :
Countdown 10...
Countdown 9...
Countdown 8...
Countdown 7...
Countdown 6...
Countdown 5...
Countdown 4...
Countdown 3...
Countdown 2...
Countdown 1...
BOOM !!!
Sounds like they want it to ignore the input parameter and always start the countdown at 10. But let's assume that they really wanted the countdown to start with the value of the input parameter.
You have an answer for a macro that uses a %DO loop.
How do you think you could do it with recursion?
Do you know what recursion is?
Do you know how to program recursion? Hint: make sure that there is a way to prevent the recursion from going on forever.
When done compare to this:
%macro countdown(start);
%if &start > 0 %then %do;
%put Countdown &start;
%countdown(%eval(&start-1))
%end;
%else %put BOOM !!!;
%mend countdown;
Thank you TOM
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.