* Many macros use procedures that require an 'open' data set in the editor, even if * the macro procedure doesn't use the data. The data list command doesn't work inside * a macro, but matrix code can be incorporated as a first line for a macro that uses * commands requiring open data. The following is a macro that uses this technique to * generate normally distributed random data. * Author: Fernando Cartwright, Ottawa, Canada * 2004/11/15. NEW FILE. DEFINE mymacro (!POS !TOKENS(1)) /*opens matrix language*/ MATRIX. COMPUTE temp=1. COMPUTE mylength=(!1-1). /*loop across the number of records specified in the macro call*/ LOOP i=1 to mylength. COMPUTE temp={temp;1}. END LOOP. /*place the records in the open data editor*/ SAVE temp /outfile=* /variables=temp. END MATRIX. COMPUTE random=RV.NORMAL(0,1). EXECUTE. !END DEFINE. /*run by specifying the number of records in the new file*/ mymacro 15.