/*
	nlogitgen

*!  VERSION 1.1.0  13feb2007
*/

VERSION 10.0

INCLUDE _std_large
INCLUDE _ht350
INCLUDE header

HELP hlp1, view("help nlogitgen")
RESET res1

DIALOG main, tabtitle("Main") ///
  label("nlogitgen - Create variable based on specification of branches")
BEGIN
  TEXT     tx_newvar         _lft      _top      _cwd3_1   .,		/*
		*/ label("Generate variable:")
  TEXT     tx_var            _lft3_2   @         @         .,		/*
		*/ label("From categorical variable:")
  EDIT     ed_newvar         _lft      _ss       _vnwd     ., max(32)	/*
		*/ label("Generate variable")
  VARNAME  vn_var            _lft3_2   @         @         .,		/*
		*/ label("From categorical variable")

  CHECKBOX ck_nolog          _lft3_3   @         _cwd3_1   .,		/*
		*/ option(nolog)					/*
		*/ label("Suppress output")

  GROUPBOX gb_branch         _lft      _ls       _iwd      _ht24h,       /*
		*/ label("Branch definitions")
  TEXT     tx_values         _ilft     _ss       _vlwd     .,		/*
	*/ label(`"Values of the categorical variable:  (separated by " | ")"')
  TEXT     tx_label          _vlsep    @         _vlrb     .,		/*
		*/ label("Label:  (optional)")
  EDIT     ed_values1        _ilft     _ss       _vlwd     .,		/*
		*/ label("Values of the categorical variable (branch 1)")
  EDIT     ed_label1         _vlsep    @         _vlrb     ., max(32)	/*
		*/ label("Label (branch 1)")
  EDIT     ed_values2        _ilft     _ms       _vlwd     .,		/*
		*/ label("Values of the categorical variable (branch 2)")
  EDIT     ed_label2         _vlsep    @         _vlrb     ., max(32)	/*
		*/ label("Label (branch 2)")
  EDIT     ed_values3        _ilft     _ms       _vlwd     .,		/*
		*/ label("Values of the categorical variable (branch 3)")
  EDIT     ed_label3         _vlsep    @         _vlrb     ., max(32)	/*
		*/ label("Label (branch 3)")
  EDIT     ed_values4        _ilft     _ms       _vlwd     .,		/*
		*/ label("Values of the categorical variable (branch 4)")
  EDIT     ed_label4         _vlsep    @         _vlrb     ., max(32)	/*
		*/ label("Label (branch 4)")
  EDIT     ed_values5        _ilft     _ms       _vlwd     .,		/*
		*/ label("Values of the categorical variable (branch 5)")
  EDIT     ed_label5         _vlsep    @         _vlrb     ., max(32)	/*
		*/ label("Label (branch 5)")
  EDIT     ed_values6        _ilft     _ms       _vlwd     .,		/*
		*/ label("Values of the categorical variable (branch 6)")
  EDIT     ed_label6         _vlsep    @         _vlrb     ., max(32)	/*
		*/ label("Label (branch 6)")
  EDIT     ed_values7        _ilft     _ms       _vlwd     .,		/*
		*/ label("Values of the categorical variable (branch 7)")
  EDIT     ed_label7         _vlsep    @         _vlrb     ., max(32)	/*
		*/ label("Label (branch 7)")
  EDIT     ed_values8        _ilft     _ms       _vlwd     .,		/*
		*/ label("Values of the categorical variable (branch 8)")
  EDIT     ed_label8         _vlsep    @         _vlrb     ., max(32)	/*
		*/ label("Label (branch 8)")
  EDIT     ed_values9        _ilft     _ms       _vlwd     .,		/*
		*/ label("Values of the categorical variable (branch 9)")
  EDIT     ed_label9         _vlsep    @         _vlrb     ., max(32)	/*
		*/ label("Label (branch 9)")
END


PROGRAM command
BEGIN
	require main.ed_newvar
	put "nlogitgen " main.ed_newvar " " "=" 
	varlist main.vn_var
	put " ("
	require main.ed_values1
	if main.ed_label1 {
		put main.ed_label1 ": "
	}
	put main.ed_values1
	require main.ed_values2
	put ", "
	if main.ed_label2 {
		put main.ed_label2 ": "
	}
	put main.ed_values2
	if main.ed_values3 {
		put ", "
		if main.ed_label3 {
			put main.ed_label3 ": "
		}
		put main.ed_values3
	}
	if main.ed_values4 {
		put ", "
		if main.ed_label4 {
			put main.ed_label4 ": "
		}
		put main.ed_values4
	}
	if main.ed_values5 {
		put ", "
		if main.ed_label5 {
			put main.ed_label5 ": "
		}
		put main.ed_values5
	}
	if main.ed_values6 {
		put ", "
		if main.ed_label6 {
			put main.ed_label6 ": "
		}
		put main.ed_values6
	}
	if main.ed_values7 {
		put ", "
		if main.ed_label7 {
			put main.ed_label7 ": "
		}
		put main.ed_values7
	}
	if main.ed_values8 {
		put ", "
		if main.ed_label8 {
			put main.ed_label8 ": "
		}
		put main.ed_values8
	}
	if main.ed_values9 {
		put ", "
		if main.ed_label9 {
			put main.ed_label9 ": "
		}
		put main.ed_values9
	}
	put ")"
	beginoptions
		option main.ck_nolog
	endoptions
END
