Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: converting variable labels to proper case with apostrophes


From   "Dimitriy V. Masterov" <dvmaster@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: converting variable labels to proper case with apostrophes
Date   Wed, 26 Jul 2006 18:22:11 -0400

Inspired by Joseph Coveney's solution, here's some code that converts
all variable and value labels to proper case. It still does not work
with things like "1st quintile" but it's saves a lot of work.

foreach var of varlist _all {;
	
local variable_label : variable label `var';
local variable_label = subinstr(proper("`variable_label '"),"'S", "'s", .);
label variable `var' "`variable_label'";

if "`:value label `var''" != "" {;
qui label list `var';
forvalues i=`r(min)'/`r(max)' {;
if "`:label `var' `i', strict'"!="" {;
local vl "`:label `var' `i', strict'";
local vl = subinstr(proper("`vl'"), "'S", "'s",.);
label define `:value label `var'' `i' "`vl'", modify;
};
};
};
};
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index