[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: extract a subset of numbers from a bigger number
Similar questions are often asked on this list.
If X is numeric,
gen newvar = mod(X,100000)
If it is string,
gen newvar = substr(X,-5,5)
For this kind of basic operation, rummaging in the
help for functions is illuminating.
> How can I extract the last 5 digits a 9-digit number
> (say a social security number) creating a new variable
> X newvar
> 999912345 ---> 12345
* For searches and help try: