29.07.2014 Views

destring - Stata

destring - Stata

destring - Stata

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4 <strong>destring</strong> — Convert string variables to numeric variables and vice versa<br />

. list<br />

id num code total income<br />

1. 111 243 1234 543 23423<br />

2. 111 123 2345 67854 12654<br />

3. 111 234 3456 345 43658<br />

4. 222 345 4567 57 23546<br />

5. 333 456 5678 23 21432<br />

6. 333 567 6789 23465 12987<br />

7. 333 678 7890 65 9823<br />

8. 444 789 8976 23 32980<br />

9. 444 901 7654 23 18565<br />

10. 555 890 6543 423 19234<br />

. <strong>destring</strong>, replace<br />

id has all characters numeric; replaced as int<br />

num has all characters numeric; replaced as int<br />

code has all characters numeric; replaced as int<br />

total has all characters numeric; replaced as long<br />

income has all characters numeric; replaced as long<br />

. describe<br />

Contains data from http://www.stata-press.com/data/r13/<strong>destring</strong>1.dta<br />

obs: 10<br />

vars: 5 3 Mar 2013 10:15<br />

size: 140<br />

storage display value<br />

variable name type format label variable label<br />

id int %10.0g<br />

num int %10.0g<br />

code int %10.0g<br />

total long %10.0g<br />

income long %10.0g<br />

Sorted by:<br />

Note:<br />

. list<br />

dataset has changed since last saved<br />

id num code total income<br />

1. 111 243 1234 543 23423<br />

2. 111 123 2345 67854 12654<br />

3. 111 234 3456 345 43658<br />

4. 222 345 4567 57 23546<br />

5. 333 456 5678 23 21432<br />

6. 333 567 6789 23465 12987<br />

7. 333 678 7890 65 9823<br />

8. 444 789 8976 23 32980<br />

9. 444 901 7654 23 18565<br />

10. 555 890 6543 423 19234

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!