Announcement

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

  • file write



    local varname swim
    levelsof `varname',local(optionlist)
    *local row=`current_row'
    foreach item of local optionlist{

    local option=`item' //option
    local option_label: label (`varname') `option'
    count
    local den `r(N)'
    count if c16==1
    local num `r(N)'
    file write my_analysis "`option_label'" _n

    file write my_analysis "`num'" _tab _n

    }

    file write my_analysis "`den'" _n
    file close my_analysis

    Am trying to do a code so that the values for each value label swim can be written just after the value labels. Any idea
    Last edited by Moses Otieno; 15 Mar 2019, 14:50.

  • #2
    Am trying to do a code so that the values for each value label swim can be written just after the value labels. Any idea
    Use labmask from Stata Journal, authored by Nick Cox.

    Code:
    sysuse census
    list region in 1/5
    decode region, gen(sregion)
    replace sregion= sregion+ string(region)
    *TYPE findit labmask AND FOLLOW INSTRUCTIONS TO INSTALL
    labmask region, values(sregion)
    list region in 1/5
    Result:

    Code:
    . list region in 1/5
    
         +--------+
         | region |
         |--------|
      1. | South  |
      2. | West   |
      3. | West   |
      4. | South  |
      5. | West   |
         +--------+
    
     list region in 1/5
    
         +--------+
         | region |
         |--------|
      1. | South3 |
      2. | West4  |
      3. | West4  |
      4. | South3 |
      5. | West4  |
         +--------+

    Comment

    Working...
    X