执行如下SAS代码后,Willis数据集包含多少列?
How Many Columns Will the SAS Dataset
Willis Contain? Let's break down this SAS data step line by line to figure out the final column count for the Willis dataset:
First, the short answer: the Willis dataset will have 4 columns: b, A, j, and lev.
Here's why each variable makes the cut:
b: This is the index variable for the outerdoloop (do b = 1 to 12;). In SAS, loop index variables are automatically included in the output dataset unless you explicitly drop them—no extra code needed to keep them around.A: Assigned in line 34 withA = rand("normal", 12.5, 1.57);. Any variable that gets a value assigned in the data step (and isn't a temporary variable) becomes a column in the resulting dataset.j: The index variable for the innerdoloop (do j = 1 to 5;). Same rule applies here as withb—loop indexes stick around in the dataset by default.lev: Calculated in line 36 withlev = rand("normal", 4, 2.155) + A;and written out with theoutput;statement. This variable is explicitly generated for the output, so it's definitely included.
A quick note on what doesn't count: The put statements (lines 32 and 40) only print text and variable values to the SAS log—they don't add any columns to the dataset itself.
内容的提问来源于stack exchange,提问作者Jeremy Wik
相关产品推荐
相关产品推荐

