Courtesy of Kit Baum, the package -unitchg- is now available on SSC. The package can be used to convert numbers and variables from one unit of measurement into another one. It contains converters for
for units of angles, areas, currencies, datastorages, datatransfers, lengths, masses, mileages, speeds, temperatures, times and volumes. The various converters include the standard SI metric measures, the various British and American variants of the imperial system (e.g. inches, gallons, acres, etc.) and some less often used measures from the so-called "Furlong-Firkin-Fortnight" System of measurement.
Examples:
Convert 1 US Dollar into British Pounds using yesterday's exchange rate:
Do the same for a variable using the average exchange rate of 1999:
The package includes a wide range of units. If something is missing I invite you to contribute via the Gitlab site of the package:
https://gitup.uni-potsdam.de/ukohler/unitchg
for units of angles, areas, currencies, datastorages, datatransfers, lengths, masses, mileages, speeds, temperatures, times and volumes. The various converters include the standard SI metric measures, the various British and American variants of the imperial system (e.g. inches, gallons, acres, etc.) and some less often used measures from the so-called "Furlong-Firkin-Fortnight" System of measurement.
Examples:
Convert 1 US Dollar into British Pounds using yesterday's exchange rate:
Code:
. unitchg 1, currency(USD) to(GBP) date(yesterday)
1 USD is .75843 GBP (at 2025-04-03)
Code:
. use http://www.stata-press.com/data/kk/data1, clear . egen incomeGBP = unitchg(income), currency(USD) to(GBP) date(1999)
https://gitup.uni-potsdam.de/ukohler/unitchg