1

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?

D. Studer
  • 1,711
  • 1
  • 16
  • 35
  • 1
    Is there a reason you need to repeat the data rows according to the count value ? SAS Procedures can use `WEIGHT ` and `FREQ ` statements to deal with weighted and presummarized (count) data. – Richard Apr 02 '20 at 15:37

1 Answers1

1

Try this

data want;
   set queries;
   do _N_ = 1 to count;
      output;
   end;
run;
PeterClemmensen
  • 4,018
  • 3
  • 14
  • 22