Hi, I am writing a loop that looks like this
foreach code of numlist 1/202{
forvalues i=1940/2020{
forvalues j=0/4{
summ y`i'q`j' if id==`code' & inlist(indicatorcode,"A", "B", "C", "D")
replace y`i'q`j'=r(sum) in 2*`code'-406
summ y`i'q`j' if id==`code' & inlist(indicatorcode,"X", "Y", "Z")
replace y`i'q`j'=r(sum) in 2*`code'-405
}
}
}
There is a problem with the replace command as STATA can't understand 2*`code'-406 where it is written. How do I make this work?
So essentially, when writing a command
replace newvar = exp in #
how can I make # into a function using a variable from foreach?
Related Posts with A function for a number
Computing rolling lagged sums with bysortDear Statalist users, I have monthly time series data on flight_delays per air_carrier. For each ai…
İnteresting Problem About Xtbunitroot test (Karavias and Tzavalis (2014)ı have N:12 T:31 panel data. ı am researching agriculture subsideies how to effect inputs costs. I w…
Computing rolling lagged sums with bysortDear Statalist users, I have monthly time series data on flight_delays per air_carrier. For each ai…
New package sscpax on SSCThanks once again to Kit Baum, a new package sscpax is now available for download from SSC. In Stata…
Saving option within a programDear All, I have the following rough code (it needs further amendements): Code: capture program …
Subscribe to:
Post Comments (Atom)
0 Response to A function for a number
Post a Comment