Hi,
I posted a problem earlier on this:
Can anyone help me with this problem?
I have two variabels:
Price Count
20.0 100
21.0 200
22.0 300
I would like to make one new variabel that gives f. ex price=20 hundred
registrations, then 21 – 200 registrations
Ex
New variable
20
20
20
etc --> hundred times (as given by countvariabel)
21
21
21
21
etc à 200 times
22
22
22
etc à 300 times
Laurel Copeland solved this for me with (thanks!):
set obs 600
gen price=20.0
replace price=21.0 if _n>100
replace price=22.0 if _n>300
This works out fine, however, my datafile have thousand of different
prices, eg. 20.1, 20.12,20.56 etc. and the count variabels is different
values for each of the prices. I am looking for a way to make syntax
that generated a new variabel like the one above, but without having to
write in the prices and counts.
-foreach- or maybe -forvalues- can solve this, but I am not sure how?
Any help would be greatly appreciated!
Best regards,
Alexander Severinsen
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/