Multiple choice technology programming languages

Which of the following examples correctly defines the macro program Hex?

  1. %macro hex(start=1, stop=10, incr=1); %local i; data null; %do i=&start to &stop by &incr; value=&i; put "Hexadecimal form of &i is " value hex6.; %end; run; %mend hex;

  2. %macro hex(start=1, stop=10, incr=1); %local i; data null; %do i=&start %to &stop %by &incr; value=&i; put "Hexadecimal form of &i is " value hex6.; %end; run; %mend hex;

  3. %macro hex(start=1, stop=10, incr=1); %local i; data null; %do i=&start to &stop by &incr; value=&i; put "Hexadecimal form of &i is " value hex6.; run; %mend hex;

  4. %macro hex(start=1, stop=10, incr=1); %local i; data null; %do i=&start to &stop by &incr; value=&i; put "Hexadeciaml form of &i is " value hex6.; %end run; %mend hex;

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In SAS macro loops, the iteration syntax requires percent signs before TO and BY: %DO variable=start %TO stop %BY increment. Options A, C, and D use the incorrect DATA step syntax (to, by without %). Option B correctly uses %TO and %BY, and properly structures the macro with %LOCAL for the loop variable and matching %END. The other options either use wrong syntax or have structural errors (missing %END, misspelling, wrong placement of RUN).