*! version 1.0.0 02/02/93 extrname utility; STB-13: dm13 program define _crcexn4 /* `v' `fmname' `lname' */ version 3.0 local v "`1'" local fmname "`2'" local lname "`3'" tempvar fword pbad bad splitstr `fword' `v' " " gen byte `pbad' = `v'=="" local type : type `fword' minlen `type' `lname' gen byte `bad' = `pbad' & `lname'=="" replace `lname'=`fword' if `bad' replace `fword'="" if `bad' drop `bad' `pbad' compress `lname' `fword' rename `fword' `fmname' end exit /* `v' `fname' `lname' v: variable to be split fname: non-existing variable lname: existing variable Split off the next token and, if v is now empty and lname is undefined, put the result in lname; otherwise, put it in fname. E.g., BEFORE AFTER BEFORE AFTER BEFORE AFTER --------------------------------------------------------------------- v Gold Bill B Gold Gold lname Gold Gold Gold fname Bill B */