Announcement

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

  • Stata 15 crashes when using unicode translate

    Dear community,

    I am using Chinese panel data for 2012 and 2014 and I've been using the
    Code:
    unicode
    command to translate the data so it appears correctly.

    My code is as follows:

    Code:
    unicode analyze *
    unicode encoding set gb18030
    unicode retranslate *, invalid(mark) transutf8
    It worked perfectly for the 2012 data but when I do the same for the 2014 data, Stata 15 unexpectedly quits. Has anyone encountered a similar issue before? Is the problem with my data file?

    I have tried on both Mac and PC computers with both Stata 14 and Stata 15. The issue is the same.

    Thank you for your help!

  • #2
    We have two users reporting the similar issue. Both are caused by the original dataset contains corrupted value label(s). The dataset works fine when the particular value label(s) are not used. But when -unicode translate- or other Stata commands try to use the corrupted value label(s), it will potentially crash Stata.

    To work around it, you may do the following,

    Code:
    // I use test.dta as an example
    
    // first we would like to save all value labels in test.dta to a do-file mylab.do
    use "test.dta", clear
    label save  _all using  mylab, replace
    
    // then we drop all value labels from the dataset, and save the new dataset as test2.dta
    label drop _all
    save test2.dta, replace
    
    // now we can translate test2.dta
    clear
    unicode encoding set gb18030
    unicode translate "test2.dta", invalid(mark) transutf8
    
    // now we translate the mylab.do
    clear
    unicode encoding set gb18030
    unicode translate mylab.do, invalid(ignore)
    
    // now we can re-attach value labels
    use "test2.dta", clear
    do mylab.do
    Now test2.dta contains translated dataset with fixed value labels, Please email Stata tech support at [email protected] with the dataset attached if the problem persists.

    Comment


    • #3
      Hua-

      Thank you so much for the help, it worked! My file has been properly translated and without any crash.

      Comment


      • #4
        Code:
        copy http://iinei.inei.gob.pe/iinei/srienaho/descarga/SPSS/348-Modulo229.zip 348-Modulo229.zip
        
        /* SPSS: .SAV >>> .dta Mario Giesel, Alemania
        DEFINE !dostuff(start = !CHAREND('/') /end = !CHAREND('/') /vars = !CMDEND)
        !DO !i = !start !TO !end
        !LET !savName = !CONCAT("H:\proyecto2\censoagp\",!i,"_IVCENAGRO_REC01.sav")
        !LET !dtaName = !CONCAT("H:\proyecto2\censoagp\",!i,"_IVCENAGRO_REC01.dta")
        GET FILE=!QUOTE(!savName)  /KEEP= !vars.
        SAVE TRANSLATE OUTFILE=!QUOTE(!dtaName).
        !DOEND
        !ENDDEFINE.
        
        !dostuff start = 348/ end = 348
         /vars = TIPO_REC P001 P002 P003 P007x P008 NPRIN WREGION LONG_DECI
        LAT_DECI P016 P017 P018  WPISO WREDHI   WP112  WP111  WP114  WP109 WALTITUD WP115 P019
        P019_01  P020_01  P022  P022_01  RESULTADO WSUP01 WSUP02 WSUP02a WSUP08.
        */
        
        clear all
        local censoagp "H:\proyecto2\censoagp"
        cd "`censoagp'"    
        
        use "348_IVCENAGRO_REC01.dta", clear
        label save  _all using  mylab, replace
        
        label drop _all
        save 348_IVCENAGRO_REC01_2.dta, replace
        
        clear
        unicode encoding set latin1
        unicode translate "348_IVCENAGRO_REC01_2.dta"
        
        clear
        unicode encoding set latin1
        unicode translate mylab.do, invalid(ignore)
        
        use "348_IVCENAGRO_REC01_2.dta", clear
        do mylab.do
        Last edited by Andrés Lahur Talavera Cuya; 25 Jul 2019, 14:07.

        Comment


        • #5
          Muy amablemente la srta Gabriela Ortiz, soporte tecnico de stata me ayudó a solucionar mi inconveniente


          Code:
          * comienzo *
          clear
          unicode erasebackups, badidea
          
          use 348_IVCENAGRO_REC01.dta, clear
          label save _all using mylab, replace
          label drop _all
          save 348_IVCENAGRO_REC01_2.dta, replace
          
          clear
          unicode encoding set latin1
          unicode translate "348_IVCENAGRO_REC01_2.dta", transutf8
          unicode translate mylab.do, transutf8
          
          use "348_IVCENAGRO_REC01_2.dta", clear
          do mylab.do
          * fin *

          Muchisimas gracias!!

          Comment

          Working...
          X