Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • name conflict error after running collapse command

    Hi,
    After running the below collapse command, I got an error on the name conflict (pasted below). Why is this for?

    foreach v of varlist TLE_ HLE_ PLE_ trim* exceeds* {
    local l "`l' (count) count`v'=`v' (mean) mean`v'=`v' (min) min`v'=`v' (max) max`v'=`v' "
    }

    collapse `l', by(Age_Group_ sample_label)

    error:
    countTLE_ = (count) TLE_
    countTLE_ = (count) TLE_
    name conflict

  • #2
    Try blanking the local macro before the loop:

    Code:
    local l
    Otherwise any previous content will just be carried forward.

    Comment


    • #3
      Great! Thanks. I have a quickly related question. How does the collapse command treat the missing values? I recall that one of the stata commands, treat them as 0 but not sure if it was collapse.

      Comment


      • #4
        As the documentation says:

        Create dataset containing the percentage of observations in each year where the totals are weighted counts of nonmissing gpa and hours
        . collapse (percent) gpa hour [fw=number], by(year)

        Collapse treats missing data as missing just like almost all other Stata procedures.

        The idea of treating missing data as zeros is one of the weird things I find in Excel sometimes.

        Comment

        Working...
        X