Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65124

Loop breaks at the same value

$
0
0
Dear All,

first of all excuse me for my English.

I have a problem, when i am programming a loop. I want to extract the Business Code and the belonging Label of the Business ID to an excel sheet. The loop works well, but every time when the same Business ID should be extracted, the loop breaks. When I split the loop in two loops and program the code for the "loop-breaking"-ID " per hand" it works well. I don't understand, why the loop breaks, when i try it over all values. Here is my Code:

Code:
 levelsof newid, local(Business)
    
    
     local test : value label newid

    foreach l of local Business {
        local b : label `test' `l'

           
  quietly summarize WZ2008n if newid == `l'
     

     local y = r(mean)
     
  
    quietly summarize AV if newid == `l' , detail
    local x = r(N)
    
    
    local row = 3 + `l'
    
  
    quietly summarize AV if newid == `l' & AV > 0.5, detail

 
    putexcel set Ergebnisse,  sheet("Uebersicht") modify
    
    putexcel B`row' = ("`y'") C`row' = ("`b'") G`row'=(`x') H`row' =(round(r(mean), .001)) I`row' = (round(r(N)/ `x', .001))

    }
When I tried to program the loop with a forvalue-loop, the same problem occurs:

Code:
forvalues l =1/44
But when I split the loops in two loops from 1/28 and 30/44 and make the calculation for 29 by Hand, it works.

Best Regards

Viewing all articles
Browse latest Browse all 65124

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>