1
votes

I have the following sample data frame:

DATA queries;
INPUT id :$12. type :$3000. count :3.;
INFILE DATALINES DSD;
DATALINES;
1, Theft, 3
2, Assault, 3
3, Murder, 1
4, Fraud, 1
;
RUN;

But I'd rather have each row repeated n times (according to the value of the count-variable). So the result should be:

id type    count
1  Theft   3
1  Theft   3    <- new
1  Theft   3    <- new
2  Assault 3
2  Assault 3    <- new
2  Assault 3    <- new
3  Murder  1
4  Fraud   1

Does anyone know how to multiply the rows in SAS?

1
Is there a reason you need to repeat the data rows according to the count value ? SAS Procedures can use WEIGHT <var> and FREQ <var> statements to deal with weighted and presummarized (count) data.Richard

1 Answers

1
votes

Try this

data want;
   set queries;
   do _N_ = 1 to count;
      output;
   end;
run;