{smcl} {.-} help for {cmd:strdate} {right:(Roger Newson)} {.-} {title:Replacing string date variables with numeric date variables with the same names} {p 8 27} {cmd:strdate} {it:varlist} [{cmd:,} {cmdab:s:2}{cmd:(}{it:string_argument}{cmd:)} {cmdab:y:cutoff}{cmd:(}{it:numeric_argument}{cmd:)} {cmdab:f:ormat}{cmd:(}{it:%format}{cmd:)} ] {p} where {it:string_argument} is either a string in quotes or a string variable name, and {it:numeric_argument} is either a number or a numeric variable name. {title:Description} {p} {cmd:strdate} takes, as input, a list of character date variables in {it:varlist}, and replaces them with a list of numeric date variables with the same names and variable labels (if any), occupying the same positions in the variable order as the original character date variables. The conversion is carried out using the {cmd:date} function. The user can specify cutoff year (for two-digit years) and date format. {title:Options} {p 0 4} {cmd:s2(}{it:string_argument}{cmd:)} is the {it:s2} string argument passed to the {cmd:date} function; see {hi:[U] 16.3.3 Date functions}. It may be a string in quotes or a string variable name. Its value should be a permutation of {hi:d}, {hi:m} and {hi:[##]y}, eg {hi:mdy} or {hi:dm20y}. {hi:##}, if specified, indicates a default century for two-digit years. For instance, {hi:dm20y} interprets "08/06/55" as 8 June, 2055. If {hi:s2} is absent, then it is set by default to {hi:dmy}. {p 0 4} {cmd:ycutoff(}{it:numeric_argument}{cmd:)} is the {it:y} numeric argument passed to the {cmd:date} function; see {hi:[U] 16.3.3 Date functions}. It may be a number or a numeric variable name. Its value should be an integer from 1000 to 9998 (but probably 2001 to 2099), specifying the handling of two-digit years. It denotes the largest year to be returned when a two-digit date is encountered. If it is absent, and there is no {hi:##} in the {cmd:s2} option, then dates with a two-digit year are set to missing. {p 0 4} {cmd:format(}{it:%fmt}{cmd:)} specifies the format assigned to the new numeric date variables. If absent, it is set to {hi:%dD_m_CY}. {title:Remarks} {p 0 0} {cmd:strdate} is used when a generic ASCII file created by a spreadsheet, containing date variables, has been input using {cmd:insheet}. The date variables will be input into Stata as string variables. {cmd:strdate} enables the user to convert these to numeric date variables without the trouble of inventing new names, or reordering variables. {title:Examples} {p 8 16}{inp:. insheet using "patient2.dat",clear}{p_end} {p 8 16}{inp:. strdate startdat stopdat}{p_end} {p 8 16}{inp:. strdate gprfdat gprldat,s("mdy") y(2050) f(%dDmCY)}{p_end} {title:Also see} {p 0 21} {bind: }Manual: {hi:[U] 16.3.3 Date functions}, {hi:[R] insheet} {p_end} {p 0 21} On-line: help for {help functions}, {help insheet} {p_end}