Skip to content

Commit

Permalink
renamed -derivescores label- to -derivescores valuelabel-; this avoid…
Browse files Browse the repository at this point in the history
…s problems when users abbreviate subcommands (Stata would not know what -derivescores l- should mean)
  • Loading branch information
dirtyhawk committed Jul 17, 2017
1 parent 9f3bbd6 commit f6074ee
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions ado/derivescores.ado
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*! derivescores.ado: Stata tool to enable structured derivation of (score) variables from classifications based on derivation tables
program define derivescores , nclass sortpreserve
version 14 // Stata version 14 or newer required
// parse subcommands: valid are "help", "setup", "list", "wipe", "info", "label", "crosswalk", "destring"
local validcmds help setup list wipe info label crosswalk destring
// parse subcommands: valid are "help", "setup", "list", "wipe", "info", "valuelabel", "crosswalk", "destring"
local validcmds help setup list wipe info valuelabel crosswalk destring
gettoken cmd 0 : 0, parse(`" ,"')
local cmdlength=length(`"`cmd'"')
// no subcommand specified -- issue error message
Expand Down
6 changes: 2 additions & 4 deletions ado/derivescores_crosswalk.ado
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
program define derivescores_crosswalk , nclass
// syntax declaration and macros
syntax varname(string) , FROMdeclaration(string) TOdeclaration(string) generate(name) [, AUXiliary(varlist) ASNUMeric ]
syntax varname(string) , FROMdeclaration(string) TOdeclaration(string) generate(name) [, AUXiliary(varlist) ASNUMeric labelname(passthru) ]
// check options, prepare macros
confirm new variable `generate', exact
local probmarkername probmarker
Expand Down Expand Up @@ -157,9 +157,7 @@ program define derivescores_crosswalk , nclass
}
// convert targetConcept to classifications prefValue, if specified
if (!missing(`"`asnumeric'"')) {
*! will work as soon as -derivescores destring- is finished *!
derivescores destring `generate' , declaration(`todeclaration') replace
derivescores label `generate' , declaration(`todeclaration')
derivescores destring `generate' , declaration(`todeclaration') replace label `labelname'
}
// quit
exit 0
Expand Down
6 changes: 5 additions & 1 deletion ado/derivescores_destring.ado
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
program define derivescores_destring , nclass
// syntax declaration and macros
syntax varname(string) , DEClaration(string) [, generate(name) replace verbose ]
syntax varname(string) , DEClaration(string) [, generate(name) replace verbose LABel labelname(passthru) ]
// set macros
local sourcevarname Concept
local targetvarname prefValue
Expand Down Expand Up @@ -119,6 +119,10 @@ program define derivescores_destring , nclass
rename (`re_renamefrom') (`re_renameto')
// label target variable
label variable `generate' `"`: variable label `varlist''"'
// if requested, value-label the new variable
if (`"`label'"'==`"label"') {
derivescores valuelabel `generate' , declaration(`declaration') `labelname'
}
// replace-scenario: interchange (temporary) new and already existing variable names
if `"`replace'"'=="replace" {
rename (`varlist' `generate') (`generate' `varlist')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------------
derivescores_label.ado: labels one or more variables with classification labels
derivescores_valuelabel.ado: value-labels one or more variables with classification labels
Copyright (C) 2017 Daniel Bela ([email protected])
Knut Wenzig
Expand All @@ -18,14 +18,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------------*/
*! derivescores_label.ado: labels one or more variables with classification labels
*! derivescores_valuelabel.ado: value-labels one or more variables with classification labels
/*
This procedure reads a classification declaration from derivescores' storage,
and value-labels one or more given numeric variables accordingly;
the numeric variables are assumed to contain "prefValues", as of
the corresponding table declaration
*/
program define derivescores_label , nclass
program define derivescores_valuelabel , nclass
// syntax declaration and macros
syntax varlist(numeric) , DEClaration(string) [, LABELname(name) Style(string) verbose replace ]
// abort if -derivescores setup- has not been run previously
Expand Down
4 changes: 2 additions & 2 deletions derivescores.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ d you should search SSC from within Stata.
d
d Requires: Stata version 14 or newer
d
d Distribution-Date: 20170716
d Distribution-Date: 20170717
d
d Authors: Daniel Bela and Knut Wenzig
d Support: {browse "https://github.com/dirtyhawk/stata-derivescores"}
Expand All @@ -21,7 +21,7 @@ f ado/derivescores_help.ado
f ado/derivescores_info.ado
f ado/derivescores_list.ado
f ado/derivescores_setup.ado
f ado/derivescores_label.ado
f ado/derivescores_valuelabel.ado
f ado/derivescores_wipe.ado
f help/derivescores.sthlp
f help/gnugpl.sthlp
Expand Down
Binary file modified derivescores.stpr
Binary file not shown.

0 comments on commit f6074ee

Please sign in to comment.