Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: strgroup

From   "Liao, Junlin" <>
To   "" <>
Subject   RE: st: strgroup
Date   Mon, 21 Feb 2011 21:00:15 +0000

I always admire people who can figure out programs to solve such messes. But sometimes that there are typos and stuff that are just difficulty to find a way to generalize. I get most raw data in Excel anyway. Sometimes I get files where data is labeled in Excel. It's just natural for me to use Excel to generate codes to quickly update labels in Stata or deal with situations like this one. Use Excel to write code is a fairly easy trick to learn.


-----Original Message-----
From: [] On Behalf Of Nick Cox
Sent: Monday, February 21, 2011 2:39 PM
To: ''
Subject: RE: st: strgroup

This answer presupposes that the original poster has a liking for using, MS Excel, which seems unnecessarily pessimistic. My suggestion is that instead of testing for equality you use -strpos()- and/or -subinstr()-.


Liao, Junlin

I had the same experiences before. One thing to look for is spaces trailing at beginning or end of string. For this kind of situation, I would use Excel to run a pivot table to find out all necessary changes and use Excel to generate the codes. Then paste the codes to a do file. Everything get fixed instantly.

Emily Farchy

Thank you so much for your help. I am trying to match some badly spelled names.  They are all in the same variable, but over different periods.  In the end I tried to do it manually (see below) but even this doesn't seem to have worked and when I run it, for many of the obs it returns '0 changes made'  I copied and pasted from the cells so can't think that I have made a typo!

Any ideas?

*Badly named heads
replace off_name  = "Drs. Makmur Syahputra, Sh" if off_name=="H. Makmur Syah Putra, Sh, Mm"
replace off_name = "Drs. H. Risuddin" if off_name=="Risuddin"
replace off_name  = "Amru Helmy Daulay Sh" if off_name=="H Amru Helmy Daulay Sh"
replace off_name  = "Drs H Abdillah Se Ak Mba" if off_name=="Drs H Abdillah Se Ak. Mba"
replace off_name  = "Dr H Sutrisno Hadi Sp.Og" if off_name==" "
replace off_name  = "Drs Zulkarnain Nasution" if off_name=="Zulkarnain Nasution"
replace off_name  = "Kol Mar Dairus Apan" if off_name=="Kol Mar (Purn) Dairus Apan"
replace off_name  = "Kol Mar Dairus Apan" if off_name=="Darius Apan"
replace off_name  = "Drs H Syamsurizal" if off_name=="Drs H Syamsurial"
replace off_name  = "Drs Thamsir Rachman" if off_name=="Drs H Raja Tamsir Rahman"
replace off_name  = "T Azmun Jaafar Sh" if off_name=="H T Azmun Jafar"
replace off_name  = "H Arwin Sh" if off_name=="Arwin As Sh"
replace off_name  = "Drs Abdullah Hich" if off_name=="Drs H Abdullah .H"
replace off_name  = "Drs H A Madjid Mu'Az Mm" if off_name=="Drs H A. Madjid Mu'Az"| off_name=="Drs H A. Madjid Mu'Az Mm"
replace off_name  = "Dr H Zulfikar Achmad Se" if off_name=="Dr H Zulfikar Achmad"
replace off_name  = "Alex Noerdin" if off_name=="Ir H Alex Noerdin Sh."
replace off_name  = "Eddy Yusuf" if off_name=="Eddy Yusuf Sh Mm"
replace off_name  = "Drs Andi Ahmad Sampurna Jaya M Si." if off_name=="H Andy Achmad S Jaya. M.Si"
replace off_name  = "Drs Abdurachman Sarbini Sh" if off_name=="Abdurrachman Sarbini"
replace off_name  = "Drs Tatang Farhanul Hakim" if off_name=="Kol Inf H. Suliana Wirata Hadi Subrata"
replace off_name  = "Itoch Tohija" if off_name=="Ir H M. Itoc Tochija Mm"
replace off_name  = "Drs Djasri St Mm." if off_name=="Drs Djasri St.Mm"
replace off_name  = "Bambang Bintoro Se" if off_name=="H Bambang Bintoro Se"
replace off_name  = "Ir Basuki Widodo" if off_name=="Ir H Basuki Widodo"
replace off_name  = "Probo Yulastoro" if off_name=="H Probo Yulastoro S Sos Mm"
replace off_name  = "Hendro Martojo" if off_name=="Drs Hendro Martojo Mm"
replace off_name  = "Dra Rustriningsih" if off_name=="Dra Hj Rustriningsih"
replace off_name  = "Hendy Boendoro Sh" if off_name=="H Hendy Boendoro Sh M Si"
replace off_name  = "Tasiman" if off_name=="H Tasiman S H."
replace off_name  = "H M Machroes Sh." if off_name=="H M Machroes S.H"
replace off_name  = "Drs Triono Budi Sasongko M Si" if off_name=="Drs Triyono Budi Sasongko"
replace off_name  = "Ir Bambang Guritno" if off_name=="H Bambang Guritno"

*   For searches and help try:

Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index