Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Importing data into Stata


From   "b. water" <[email protected]>
To   [email protected]
Subject   Re: st: Importing data into Stata
Date   Fri, 16 Dec 2005 11:53:28 +0000

Stata 8.2 Window XP Pro SP2.

Thanks to Richard Goldstein & Nick Cox for their advice. Split and parse with destring works well and overcome my defective substr (see below). Here are my substr tries (v1 is my data authors (year) variable following insheet) and the accompanying error messages:

. substr(v1,-6,.)
unrecognized command: substr
r(199);

. substr("v1",-6,.)
unrecognized command: substr
r(199);

. substr("abcdef",2,3)
unrecognized command: substr
r(199);

Any explanation for the error messages? The last example was taken straight from the manual [R] functions substr(s,n1,n2).

Kind regards,
bw


From: Richard Goldstein <[email protected]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: st: Importing data into Stata
Date: Thu, 15 Dec 2005 14:25:05 -0500

use the -split- command on your three variables; then use the substr function to strip off the parentheses from the year variable

Rich

b. water wrote:

Dear all,

Stata 8.2 Window XP Pro SP2.

I want to import into Stata a data set saved as a text file, which contained data in the following structure:

Abrams (1999) 0/31 5/232
Greenland (1996) 115/2131 123/8751
Di Arozio (1999) 4/12 21/483

i.e. authors space year (in bracket) tab number nospace forward/slash nospace number tab number nospace forward/slash nospace number. I want to end up with six columns of variables in Stata i.e. authors year (without brackets) number number number number.

I am at lost as to what to do with what looks like a very structured data set and should be able to be accomplished without difficulty. I checked [U] 24 Commands to input data and [R] infile, infix and insheet for help but without success.

I tried to copy and paste into stata editor and ended up with three columns of variable i.e. authors and years, number/number and number/number. In this situation, I do not know how (beyond me - to create a do-file) to 'clean' the data e.g. 'demerging' authors and years from one column to two columns and likewise for number/number from one column to number number in two separate columns.

Would be grateful for any help and advice.

Kind regards,
bw

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee� Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

*
* 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/


_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement

*
* 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