Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Antwort: st: LA-AIDS model: saving parts of a dataset using forvalue


From   Richard Ochmann <[email protected]>
To   [email protected]
Subject   Antwort: st: LA-AIDS model: saving parts of a dataset using forvalue
Date   Mon, 15 Nov 2010 09:42:45 +0100

> forv item13 = 1/13{
>  keep if `item13' == `i'
>  rename price p`i'
>  save item_`i'
>  restore, preserve
>  }

Christian,
it is not clear to me what you want to do in this loop. the way you write 
it, it looks for variables named 1,2,3,... up to 13, which i doubt appear 
in your data set. also, local i apparently is not defined. it might be 
that you need a nested loop here in addition, but that is not clear so 
far.

best, rich

[email protected] schrieb am 13.11.2010 10:19:58:

> Dear All,
> 
> I am running a AIDS model and I want to aggregate price and food 
consumption
> by item.
> I decided to aggregate first both price and food consumption, then 
separate
> the file by items and append them later.
> However, my code is now working when it comes to separate files by 
items.
> Any suggestion is welcome.
> 
> Here is my code:
> 
> * 5.  Aggregate food and price
> use dataset, clear
> gen price = value / quant
> label var price "Price"
> collapse (sum) value (sum ) price, by(id item13)
> save file05, replace
> * 6.  Separate file by item
> use file05, clear
> forv item13 = 1/13{
>  keep if `item13' == `i'
>  rename price p`i'
>  save item_`i'
>  restore, preserve
>  }
> 
> 1
> invalid syntax
> r(198);
> 
> end of do-file
> 
> 
> Christian Otchia
> -- 
> View this message in context: http://statalist.1588530.n2.nabble.
> com/LA-AIDS-model-saving-parts-of-a-dataset-using-forvalue-
> tp5735067p5735067.html
> Sent from the Statalist mailing list archive at Nabble.com.
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index