Your "if" is wrong to execute in macro processing, it should be %if.
To call data step functions you have to use %sysfunc(function(parameters))
%macro xyz; %do i=1 %to 20 ; %if %sysfunc (mod(&i,2))=0 %then %do; %end; %end; %mend;
%macro xyz; %do i=1 %to 20 ; data even; %if %sysfunc (mod(&i,2))=0 %then %do; %end; run; %end; %mend; %xyz;
NOW you really need to describe everything that you are actually attempting to do. %if code does not recognize the values of data step variables. Macro statements inside data step must generate valid data step (or other procedure) code. Since the code you show does not generate data step code it does nothing except create a data set named even, with no variables and gets overwritten 19 times after initial creation.
At this point I would say that one possible "solution" is : 42 .
As always, @Anandkvn we need much more explanation from you. Your posts are consistently too brief, causing us to guess and often guess wrong and then we have to ask follow-up question after follow-up question. Explain. Provide details about what you are trying to do, in words, not SAS code, and explaining the background and reasons. Emphasis on details. Emphasis on background. Emphasis on explain. Don't make us constantly ask you for additional details and ask why you are doing this; provide all relevant details in the first post. We're trying to help you, but you have to help us.
Your code (once corrected to use %IF and %SYSFUNC) will do nothing, so it's not worth bothering with.
Rule #1 of macro development: start with working, non macro code. So please show the code you want to make dynamic, and describe what needs to be repeated, and how.
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.
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.