I am trying to generate/create data in SAS that has the following form (see below) where class1-class5 variables will be filled with a random integer from 1-6. I am trying to do this with array and do loops via the following code data classes; /* createa a dataset of students */
array class{5} class1-class5;
call streaminit(123);
do i = 1 to 20;
student=i;
do j=1 to dim(class);
class{j} = rand("INTEGER",1,6); /* class ~ U(1,6) */
output;
end;
end;
run; This does not work. I really don't understand why I am getting so many observations. I am finding do loops very counterintuitive in SAS compared to other programming languages. Student Class1 Class2 Class3 Class4 Class5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
... View more