*! version 1.0.0 02/02/93 extrname utility; STB-13: dm13 program define _crcexn2 /* `exword' varname word certword intovar */ version 3.0 local v "`1'" local word "`2'" local cword "`3'" local into "`4'" tempvar new quietly { local d = length("`cword'") minlen `d' `into' local type : type `v' gen `type' `new'=`v' replword "`word'" "" 1 `new' replace `new'=`v' if `into'!="" replace `into'="`cword'" if `new'!=`v' replace `v'=trim(`new') drop `new' compress `v' compress `into' } end exit /* E.g., `exword' myvar "jr." "Jr." exvar Removes word "jr." from myvar where exvar=="" and then places "Jr." in exvar where the word was removed lengths of variables is handled automatically. */