Bookmark and Share

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


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

st: Dropping Alphanumeric elements from variables


From   "Michler, Jeffrey D" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Dropping Alphanumeric elements from variables
Date   Thu, 7 Feb 2013 13:37:26 +0000

I have a dataset which includes household ID variables in an alphanumeric format. The letters are abbreviations of the village a household comes from.  In addition to being in an alphanumeric format, the HH ID has a year element so that the HH ID for 2010 is slightly different than it was for 2009.  I am looking to convert the alphanumeric HH id into a unique id for constructing a panel. I need to replace the 3 letter village abbreviations with a 3 digit number plus I need to drop the year id.

An example may clarify. Right now HH IDs look like BTG09A00001, BTG10A00001, BGM09A00027, BGM10A00027.

I want to replace the village code (BTG, BGM) with a numerical sequence. I also want to drop the year sequence (09, 10) so that HH ID is consistent for the HH across years, and I want to drop the A, which plays to role in my dataset. Ideally, this would compress the 4 HH ID I gave as examples into just 2 IDs that would look like 10100001 and 10200027.

Any help would be greatly appreciated.

Jeffrey D. Michler

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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