editing large numbers of observations in stata

Hi there,

I have a variable with many observations of the sort: 45.34.12 or 66.97.03. These are time measurements (yes I know, ill-considered format for specifying time). I am trying to create a variable that represents the difference between this and another variable with time measurement in the same format (e.g. 45.34.12 - 45.36.06).

Obviously, because these are not real numbers, stata will not be able to perform the arithmetic. Luckily, the numbers before the first decimal are irrelevant, and always the same within an observation (so that the above example is really just 34.12 - 36.06). How can I get stata to uniformly lop off the first two numbers in every observation for these variables, and thus make subtraction of the two columns possible?



I haven’t used Stata in a while, but I think this is simple:

replace Varname=substr(Varname, 4, .)

I think that’ll remove the first 3 characters from your variable (or rather, return 4th-end characters), though you may want to use gen to test rather than replace.

You’d probably be better off applying a datetime format to your variable.