Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Splitting numeric values


From   "Karl Keesman" <[email protected]>
To   <[email protected]>
Subject   st: Re: Splitting numeric values
Date   Mon, 23 Jul 2007 09:13:57 -0700

Hi,

You can recast as an integer  eg.

***************************
clear

input a

610102001001010300

end

recast int a, force

d

tostring a, replace

d

***************************

Regards

Karl







----- Original Message -----
From: "Susan Olivia" <[email protected]>
To: <[email protected]>
Sent: Sunday, July 22, 2007 3:30 PM
Subject: st: Splitting numeric values


> Hi,
>
> I have a numeric variable (call it id) that comes with 18 digits and I
> would
> like to create a new variable that extracts from the variable 'id'
> starting
> from the 10th digits and get 4 digits from here.
>
> E.g. my id is given as: 610102001001010300 and I want to create 'newvar'
> which has value of 0010.
>
> I know this can be easily done using the 'substr' command, however, I am
> having a problem in converting the 'id' into string variable. It gives me
> the following command:
>
> ***
> tostring id, replace
> id cannot be converted reversibly; no replace
>
> ***
>
> Any advice on how to handle this would be much appreciated.
>
> Thanks,
>
> Susan
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
>
>


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index