The %MktKey autocall macro creates expanded lists of variable names and creates an output data set named Key
. This macro is most commonly used to create KEY= input data sets for the %MktRoll macro.
%MktKey ( list )
You can specify either of the following to display the option names and simple examples of the macro syntax:
%mktkey(help) %mktkey(?)
This example uses the %MktKey macro to create a key data set for that contains 5 rows and 10 columns and variable names, X1
–X50
. You can specify the number of rows followed by the number of columns as follows:
%mktkey(5 10)
Figure 1 shows the resulting Key
output data set.
Figure 1: %MktKey(5 10) Data Set
Alternatively, you can specify the number of rows and number of columns followed by a t
or T
and get the transpose of this data set. The output data set is again called Key
. The following statement demonstrates this option:
%mktkey(5 10 t)
Figure 2 shows the resulting Key
output data set. This time the names progress down the columns instead of across the rows.
Figure 2: %MktKey(5 10 t) Transposed Data Set
The %MktKey macro also has another type of syntax. You can provide a list of variables to the %MktKey macro as follows:
%mktkey(x1-x15)
The %MktKey macro produces the following line in your SAS log:
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15
You can copy and paste this list to make it easier to construct the KEY= data set for the %MktRoll macro. The following statements create the Key
data set:
data key; input (x1-x5) ($); datalines; x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 . . . . . ;