Announcement

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

  • Converting a string variable into numeric with values 0, 1 and 2

    I have a string variable of auditor names called FSauditor that has a total of 4438 observations. I have generated a new variable called BigFSaudit which, currently, is all zeros (I used the command gen BigFSaudit = 0)

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str112 FSauditor float BigFSaudit
    "KPMG"                                                  0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "BDO "                                                  0
    "Ernst & Young"                                         0
    "Grant Thornton"                                        0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Galaz, Yamazaki, Ruiz Urquiza, SC"                     0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "Beltran, Gris y Asociados S. Civil de R.L"             0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "Deloitte & Associes, Ernst & Young Et Autres"          0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Caipo y Asociados"                                     0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "BDO "                                                  0
    "Grant Thornton"                                        0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "BDO "                                                  0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "BDO "                                                  0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "BDO "                                                  0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Galaz, Yamazaki, Ruiz Urquiza, SC"                     0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "Galaz, Yamazaki, Ruiz Urquiza, SC"                     0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "BDO "                                                  0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "BDO "                                                  0
    "BDO "                                                  0
    "PricewaterhouseCoopers"                                0
    "Galaz, Yamazaki, Ruiz Urquiza, SC"                     0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "BDO "                                                  0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "Galaz, Yamazaki, Ruiz Urquiza, SC"                     0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "ORD Partners"                                          0
    "BDO "                                                  0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "Medina, Zaldivar, Paredes & Associations"              0
    "Ernst & Young"                                         0
    "Pannell Kerr Forster"                                  0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "Medina, Zaldivar, Paredes & Associations"              0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Associes, Ernst & Young Et Autres"          0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "BDO "                                                  0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Grant Thornton"                                        0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Middel & Partners"                                     0
    "PricewaterhouseCoopers"                                0
    "ShineWing (HK) CPA Limited"                            0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Middel & Partners"                                     0
    "Shu Lun Pan Certified Public Accountants Co., Ltd"     0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Chaturvedi & Company"                                  0
    "De Chakraborty & Sen"                                  0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "Mazars, Ernst & Young et Autres"                       0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    ".n"                                                    0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers Audit, Ernst & Young et Autres" 0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "Auditor General - Thailand"                            0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "BDO "                                                  0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Auditor General - Thailand"                            0
    "Deloitte & Touche LLP"                                 0
    "Auditor General - Thailand"                            0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers Audit, Ernst & Young et Autres" 0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    ".n"                                                    0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "PricewaterhouseCoopers Audit, Ernst & Young et Autres" 0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Mazars, Ernst & Young Audit"                           0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Auditor General - Thailand"                            0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Auditor General - Thailand"                            0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young, PricewaterhouseCoopers"                 0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "BDO "                                                  0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Grant Thornton"                                        0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "KPMG"                                                  0
    ".n"                                                    0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "Grant Thornton"                                        0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    ".n"                                                    0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "Xavier BOUSQUET, Deloitte & Associes"                  0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "Grant Thornton"                                        0
    "KPMG"                                                  0
    "Samjung Public Account Firm"                           0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Grant Thornton"                                        0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "KPMG"                                                  0
    "KPMG"                                                  0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Ernst & Young"                                         0
    "Deloitte & Touche LLP"                                 0
    "KPMG"                                                  0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    "PricewaterhouseCoopers"                                0
    "PricewaterhouseCoopers"                                0
    "Ernst & Young"                                         0
    "Ernst & Young"                                         0
    ".n"                                                    0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche, KPMG "                              0
    "PricewaterhouseCoopers"                                0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche LLP"                                 0
    "Deloitte & Touche, KPMG "                              0
    "PricewaterhouseCoopers"                                0
    "KPMG"                                                  0
    "Horwath Maroc Audit, Igrec"                            0
    end








    I want to replace BigFSaudit with 1 if the string var FSauditor has the following values:

    Mazars, Ernst & Young et Autres
    Mazars, Ernst & Young Audit
    Xavier BOUSQUET, Deloitte & Associes
    Deloitte & Associados, SROC SA
    Deloitte & Associes, Mazars
    RSM Ouest,Ernst & Young Atlantique
    Auditeurs et Conseils Associes, Ernst & Young
    Deloitte & Touche, Grant Thornton
    ERNST& YOUNG Audit,Audit Conseil Expertise, SA
    Novances-David & Associés, Deloitte & Associés
    Diagnostic Revision Counseil,Ernst & Young et Autres
    Deloitte Haskins & Sells, Chaturvedi & Shah, Rajendra & Co.
    Deloitte Hadjipavlou, Sofianos & Cambanis S.A.
    Deloitte Haskins & Sells, G. P. Kapadia & Co.
    KPMG Audit, MAZARS
    Mazars, PricewaterhouseCoopers Audit
    Bellot Mullenbach & Associés, PricewaterhouseCoopers Audit
    PricewaterhouseCoopers, Mazars
    KPMG Audit, Grant Thornton
    Grant Thornton, Ernst & Young et Autres
    KPMG S.A, Mazars
    PricewaterhouseCoopers Inc, SizweNtsalubaGobodo Inc
    RSM Ouest audit, KPMG SA
    Deloitte & Associes, Ernst & Young et Autres, Mazars
    KPMG Audit, Acorex Audit
    KPMG Audit, Fiduciare Metropole Audit
    Samson Bélair/Deloitte & Touche s.e.n.c.r.l.
    Mazars, KPMG Audit, Deloitte & Associes
    Deloitte & Associés, PricewaterhouseCoopers LLP, Mazars
    JLS Partner,Deloitte & Associes
    H.C. Watt & Company Limited, PricewaterhouseCoopers
    AACE Ile-de-France, Ernst & Young Audit
    Cabinet Didier Kling & Associés, Deloitte & Associés
    Cabinet Denjean, Ernst & Young Audit
    KPMG Audit, MB Audit
    PricewaterhouseCoopers Audit, Cagnat & Associes
    Ernst & Young, Salustro Reydel
    PricewaterhouseCoopers, Fidexco France
    Saint Honore BK&A, Deloitte & Associés
    PricewaterhouseCoopers, Grant Thornton
    KPMG Ford Rhodes, Thornton & Co.








    Further, I want to replace BigFSaudit with 2 if the string var FSauditor has the following values:

    KPMG
    Deloitte & Touche LLP
    Ernst & Young
    PricewaterhouseCoopers
    Deloitte & Associes, Ernst & Young Et Autres
    PricewaterhouseCoopers Audit, Ernst & Young et Autres
    Ernst & Young, PricewaterhouseCoopers
    Deloitte & Touche, KPMG
    KPMG Inc, PricewaterhouseCoopers Inc
    Ernst & Young, KPMG
    Deloitte & Touche, PricewaterhouseCoopers





    If the value of FSauditor is missing (".n" above in the dataex list), then BigFSaudit should also be .n.



    What is the most efficient way to achieve this? I would rather not use lots of -replace....if- statements. I tried using -inlist-, but it does not take more than 10 strings.
    Last edited by Sunita Rao; 12 Aug 2018, 13:16.

  • #2
    So the simplest way to do this is to combine the two lists into a Stata data file and then merge that into your original data set. The following code illustrates the approach:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str59 FSauditor float auditor_group
    "Mazars, Ernst & Young et Autres"                             1
    "Mazars, Ernst & Young Audit"                                 1
    "Xavier BOUSQUET, Deloitte & Associes"                        1
    "Deloitte & Associados, SROC SA"                              1
    "Deloitte & Associes, Mazars"                                 1
    "RSM Ouest,Ernst & Young Atlantique"                          1
    "Auditeurs et Conseils Associes, Ernst & Young"               1
    "Deloitte & Touche, Grant Thornton"                           1
    "ERNST& YOUNG Audit,Audit Conseil Expertise, SA"              1
    "Novances-David & Associés, Deloitte & Associés"            1
    "Diagnostic Revision Counseil,Ernst & Young et Autres"        1
    "Deloitte Haskins & Sells, Chaturvedi & Shah, Rajendra & Co." 1
    "Deloitte Hadjipavlou, Sofianos & Cambanis S.A."              1
    "Deloitte Haskins & Sells, G. P. Kapadia & Co."               1
    "KPMG Audit, MAZARS"                                          1
    "Mazars, PricewaterhouseCoopers Audit"                        1
    "Bellot Mullenbach & Associés, PricewaterhouseCoopers Audit" 1
    "PricewaterhouseCoopers, Mazars"                              1
    "KPMG Audit, Grant Thornton"                                  1
    "Grant Thornton, Ernst & Young et Autres"                     1
    "KPMG S.A, Mazars"                                            1
    "PricewaterhouseCoopers Inc, SizweNtsalubaGobodo Inc"         1
    "RSM Ouest audit, KPMG SA"                                    1
    "Deloitte & Associes, Ernst & Young et Autres, Mazars"        1
    "KPMG Audit, Acorex Audit"                                    1
    "KPMG Audit, Fiduciare Metropole Audit"                       1
    "Samson Bélair/Deloitte & Touche s.e.n.c.r.l."               1
    "Mazars, KPMG Audit, Deloitte & Associes"                     1
    "Deloitte & Associés, PricewaterhouseCoopers LLP, Mazars"    1
    "JLS Partner,Deloitte & Associes"                             1
    "H.C. Watt & Company Limited, PricewaterhouseCoopers"         1
    "AACE Ile-de-France, Ernst & Young Audit"                     1
    "Cabinet Didier Kling & Associés, Deloitte & Associés"      1
    "Cabinet Denjean, Ernst & Young Audit"                        1
    "KPMG Audit, MB Audit"                                        1
    "PricewaterhouseCoopers Audit, Cagnat & Associes"             1
    "Ernst & Young, Salustro Reydel"                              1
    "PricewaterhouseCoopers, Fidexco France"                      1
    "Saint Honore BK&A, Deloitte & Associés"                     1
    "PricewaterhouseCoopers, Grant Thornton"                      1
    "KPMG Ford Rhodes, Thornton & Co."                            1
    "KPMG"                                                        2
    "Deloitte & Touche LLP"                                       2
    "Ernst & Young"                                               2
    "PricewaterhouseCoopers"                                      2
    "Deloitte & Associes, Ernst & Young Et Autres"                2
    "PricewaterhouseCoopers Audit, Ernst & Young et Autres"       2
    "Ernst & Young, PricewaterhouseCoopers"                       2
    "Deloitte & Touche, KPMG"                                     2
    "KPMG Inc, PricewaterhouseCoopers Inc"                        2
    "Ernst & Young, KPMG"                                         2
    "Deloitte & Touche, PricewaterhouseCoopers"                   2
    end
    tempfile auditor_index
    save `auditor_index'
    
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str112 FSauditor
    "KPMG"                                                
    "KPMG"                                                
    "KPMG"                                                
    "KPMG"                                                
    "KPMG"                                                
    "KPMG"                                                
    "KPMG"                                                
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "BDO "                                                
    "Ernst & Young"                                        
    "Grant Thornton"                                      
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Galaz, Yamazaki, Ruiz Urquiza, SC"                    
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "Beltran, Gris y Asociados S. Civil de R.L"            
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "KPMG"                                                
    "Ernst & Young"                                        
    "KPMG"                                                
    "Deloitte & Associes, Ernst & Young Et Autres"        
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Caipo y Asociados"                                    
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "BDO "                                                
    "Grant Thornton"                                      
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "Ernst & Young"                                        
    "KPMG"                                                
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "BDO "                                                
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "BDO "                                                
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "BDO "                                                
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "KPMG"                                                
    "Ernst & Young"                                        
    "KPMG"                                                
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Galaz, Yamazaki, Ruiz Urquiza, SC"                    
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "KPMG"                                                
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "Galaz, Yamazaki, Ruiz Urquiza, SC"                    
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "BDO "                                                
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "BDO "                                                
    "BDO "                                                
    "PricewaterhouseCoopers"                              
    "Galaz, Yamazaki, Ruiz Urquiza, SC"                    
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "BDO "                                                
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "Galaz, Yamazaki, Ruiz Urquiza, SC"                    
    "KPMG"                                                
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "KPMG"                                                
    "ORD Partners"                                        
    "BDO "                                                
    "Ernst & Young"                                        
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "KPMG"                                                
    "Medina, Zaldivar, Paredes & Associations"            
    "Ernst & Young"                                        
    "Pannell Kerr Forster"                                
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "Medina, Zaldivar, Paredes & Associations"            
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Deloitte & Associes, Ernst & Young Et Autres"        
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "BDO "                                                
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Grant Thornton"                                      
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "Ernst & Young"                                        
    "KPMG"                                                
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Middel & Partners"                                    
    "PricewaterhouseCoopers"                              
    "ShineWing (HK) CPA Limited"                          
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Middel & Partners"                                    
    "Shu Lun Pan Certified Public Accountants Co., Ltd"    
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Chaturvedi & Company"                                
    "De Chakraborty & Sen"                                
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "Mazars, Ernst & Young et Autres"                      
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    ".n"                                                  
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "PricewaterhouseCoopers Audit, Ernst & Young et Autres"
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "Auditor General - Thailand"                          
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "BDO "                                                
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Auditor General - Thailand"                          
    "Deloitte & Touche LLP"                                
    "Auditor General - Thailand"                          
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "PricewaterhouseCoopers Audit, Ernst & Young et Autres"
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "KPMG"                                                
    ".n"                                                  
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "PricewaterhouseCoopers Audit, Ernst & Young et Autres"
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Mazars, Ernst & Young Audit"                          
    "Ernst & Young"                                        
    "KPMG"                                                
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Auditor General - Thailand"                          
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Auditor General - Thailand"                          
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Ernst & Young, PricewaterhouseCoopers"                
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "BDO "                                                
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Grant Thornton"                                      
    "KPMG"                                                
    "KPMG"                                                
    "KPMG"                                                
    ".n"                                                  
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "Grant Thornton"                                      
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    ".n"                                                  
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "KPMG"                                                
    "Xavier BOUSQUET, Deloitte & Associes"                
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "Grant Thornton"                                      
    "KPMG"                                                
    "Samjung Public Account Firm"                          
    "Ernst & Young"                                        
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "KPMG"                                                
    "KPMG"                                                
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Grant Thornton"                                      
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "KPMG"                                                
    "KPMG"                                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Ernst & Young"                                        
    "Deloitte & Touche LLP"                                
    "KPMG"                                                
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    "PricewaterhouseCoopers"                              
    "PricewaterhouseCoopers"                              
    "Ernst & Young"                                        
    "Ernst & Young"                                        
    ".n"                                                  
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche, KPMG "                            
    "PricewaterhouseCoopers"                              
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche LLP"                                
    "Deloitte & Touche, KPMG "                            
    "PricewaterhouseCoopers"                              
    "KPMG"                                                
    "Horwath Maroc Audit, Igrec"                          
    end
    
    merge m:1 FSauditor using `auditor_index'
    replace auditor_group = 0 if missing(auditor_group)
    replace auditor_group = .n if FSauditor == ".n"
    Note: Here I have saved the list of auditors in groups 1 and 2 as a temporary Stata file, but if you are going to make other use of this information, it would probably make sense to save it as a regular permanent .dta file.

    The variable auditor_group is the result you want.

    Added: Of course, the code will fail (as would any code attempting to solve this problem) if there are spelling errors in the names, or if names are sometimes written with extra spaces. The latter can be dealt with by -replace FSauditor = trim(itrim(FSauditor))-, but spelling errors have no automatic solution. So after running this code you need to scrutinize all of the values of FSauditor that came out 0 to be sure that they are not just due to typographical problems in the name.
    Last edited by Clyde Schechter; 12 Aug 2018, 13:33.

    Comment


    • #3
      Dear Prof. Schechter,

      With -replace FSauditor = trim(itrim(FSauditor))-, your merge suggestion worked beautifully!

      You have helped me with code so many times times. A Special BIG Thank you to you!

      Your suggestion saved me tons of trouble and a lot of -replace- statements!

      Sincerely,
      Sunita Rao

      Comment

      Working...
      X