Learning Stata

2015-11-05  本文已影响90人  多多爸

Collecting stata commands that are very useful but not used frequently, namely, those I can not remember well. It will get very long ...
*This post was editted by * Maxico (a Markdown *based editor for * Evernote *) first, then copied here. * The Maxico version looks much better.

  • V - Commands regarding Variables
  • M - Macros, i.e., local and global
  • F - Read, import, or export Files
  • SSC - Commands from SSC
  • F - Useful Functions

V

Variable Labels

Transfer a variable label to another

-- By Nicholas J. Cox

Copy variable labels before collapse

A systematic way to do this is with a foreach loop.

foreach v of var * {
  local l`v' : variable label `v'
    if `"`l`v''"' == "" {
        local l`v' "`v'"
        }
    }

Then after reshape check all variable labels and replace blanks by any saved labels:

foreach v of var * { 
    local L`v' : variable label `v' 
        if `"`L`v''"' == "" & `"`l`v''"' != "" { 
            label var `v' `"`l`v''"' 
    }
} 

-- By Nicholas J. Cox

M

Use of a global

di "${gl`i'}"

F

Import data from other sources (New in STATA 2013)

Import is a new command in State 13. It can import -excel- file directly. It also replace the insheet using command.

Import from Excel file

This needs some special notes because it is really a great update for STATA 13.0.

Import from a delimited text file

SSC commands

sec family; ssc hot

F

String Functions

destring

上一篇下一篇

猜你喜欢

热点阅读