File restructure #1
This commit is contained in:
@ -1,57 +0,0 @@
|
||||
*! version 1 19september2018
|
||||
*! Jean-Benoit Hardouin
|
||||
*
|
||||
************************************************************************************************************
|
||||
* Stata program : mdreplace
|
||||
* Missing data handling in a dataset
|
||||
*
|
||||
* Historic
|
||||
* Version 1 (2018-09-19): Jean-Benoit Hardouin
|
||||
*
|
||||
* Jean-benoit Hardouin, Plateforme de Méthodologie et de Biostatistique - DRCi - CHU de Nantes - France
|
||||
* jean-benoit.hardouin@univ-nantes.fr
|
||||
*
|
||||
* Copyright 2018 Jean-Benoit Hardouin
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
************************************************************************************************************
|
||||
|
||||
program define mdreplace
|
||||
version 7.0
|
||||
syntax varlist(min=1) , list(string)
|
||||
|
||||
if "`list'"=="" {
|
||||
di in red "Please indicate in the list option the strings to replace by missing data"
|
||||
}
|
||||
|
||||
foreach i of varlist `varlist' {
|
||||
foreach e in `list' {
|
||||
*di "variable : `i' code : `e'"
|
||||
|
||||
capture replace `i'="." if `i'=="`e'"
|
||||
if (_rc==0) {
|
||||
qui replace `i'="" if `i'=="`e'"
|
||||
}
|
||||
}
|
||||
capture destring `i', replace
|
||||
if (_rc==0) {
|
||||
qui destring `i', replace
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user