Dear All,

How do we create a number of cases according to the number in a variable. For example I want to create 10 cases for the number_case in the first case and so on. In my dataset I have dcode towncode lapcode eacode householdsinframe number_cases. I want to create 10 cases where the number_cases is 10 and 12 where the number_cases is 12. The other variables will be the same for the first 10 cases and the other 12 will have the same for the 12 cases.

Old data set
dcode towncode lapcode eacode householdsinframe number_cases
1 1 1 1 1 1 10

the new data set should have
dcode towncode lapcode eacode householdsinframe number_cases
1 1 1 1 1 1 1
1 1 1 1 1 1 2
1 1 1 1 1 1 3
1 1 1 1 1 1 4
1 1 1 1 1 1 5
1 1 1 1 1 1 6
1 1 1 1 1 1 7
1 1 1 1 1 1 8
1 1 1 1 1 1 9
1 1 1 1 1 1 10

An example of the data set

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(dcode towncode lapcode eacode householdsinframe number_cases)
12 51 1  2 27 10
12 51 1  6 44 12
12 51 2  1 37 10
12 51 2  5 36 15
12 51 3  4 27 14
12 51 4  5 46 10
12 51 5  3 38 10
12 52 1  2 26 10
12 52 1  7 26 10
12 52 1 13 46 20
12 52 2  1 55 60
12 52 2  5 36 10
12 52 2 11 56 10
12 61 1  2 48 10
end
------------------ copy up to and including the previous line ------------------