* Macro to extract bits from an integer. NEW FILE. DATA LIST FREE /nb. BEGIN DATA 1 2 3 4 5 6 7 8 9 10 20 30 40 100 257 2000 5555 END DATA. *////////////// . DEFINE !getbits(!POS=!TOKENS(1)) !LET !maxnb=16 VECTOR bits(!maxnb). RECODE bits1 TO !CONCAT(bits,!maxnb) (ELSE=0). FORMATS bits1 TO !CONCAT(bits,!maxnb)(F8). VARIABLE WIDTH bits1 TO !CONCAT(bits,!maxnb)(5). COMPUTE #nb=!1. LOOP #idx=!maxnb TO 1 BY -1. - DO IF #nb GE 2**(#idx - 1). - COMPUTE bits(#idx)=1. - COMPUTE #nb=#nb - 2**(#idx - 1). - END IF. END LOOP. !ENDDEFINE. *////////////. SET MPRINT=yes. !getbits nb. SET MPRINT=no. EXECUTE.