Announcement

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

  • Append files (change variable type)

    Hello,

    I am reading my friend's STATA code, which is to append several data file.

    But before append files, she did the following step, which she notes as "change variable type so that we can append".

    save "$folder/data_panel/2004panel.dta", replace
    use "$folder/data_panel/2005panel.dta", clear
    tostring CIIU4 REGION, replace

    I do not understand why do we need to change variable type, by using "tostring" ?Actually all the files used for appending included identical variables.

    If someone has an idea, plz kindly help me.

    Thank you in advance!

  • #2
    The need happens occasionally, in particular if the datasets were originally read into Stata as text files (.csv). If a variable is intended to be a string, but in one subset all of the values happen to have only numerals, then import delimited will read that variable in that .csv file as numeric and not string. When it comes time to append the resulting datasets, you'll need to convert that subset's variable to string.

    Comment

    Working...
    X