program define diformat
version 8.2

*This program changes the display format for all variables with value labels to
*the maximum length for the value label.  The display format for variables that
*don't have value labels are unchanged.
*The syntax for this command is:
*	diformat var1 var2
*	  where var1 is the first variable in the dataset and var2 is the last.

foreach var of varlist `1'-`2' {
	local diformat : label (`var') maxlength
	  if `diformat'>0 {
		format `var' %`diformat'.0g
	  }
}

end