Go Back   TestMagic Forums > Admissions > PhD in Economics
Register FAQForum Rules Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old 06-20-2008, 05:01 PM   #1 (permalink)
evilbert
Trying to make mom and pop proud
 
Join Date: Mar 2008
Posts: 17
evilbert just joined TestMagic.
STATA misreading data

I'm sure this probably isn't the place for these kind of questions....nonetheless i find most of the stata websites just full of jargon that doesn't help

i'm importing a data set into stata from excel and all of my 18 or so variables are all treated fine..except for GDP per capita PPP. for some reason STATA seems to think that this is a string variable and thus won't let me use it in any of my regressions...any ideas for combating this.

would it be because the actual figures are bigger than the other numbers in the data set?

Or could it be because observations for some years are missing?

i've tried playing around with these different factors but to no avail so far.

any ideas would be great appreciated
evilbert is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Google Bookmark this Post!Reddit!
Reply With Quote
Old 06-20-2008, 05:41 PM   #2 (permalink)
asquare
TestMagic Guru
Moderator
 
Join Date: Mar 2006
Location: Ann Arbor
Posts: 1,302
asquare is a member of the TestMagic inner circle.asquare is a member of the TestMagic inner circle.asquare is a member of the TestMagic inner circle.asquare is a member of the TestMagic inner circle.
Are there leading or trailing spaces? Commas? Any non numeric character -- even in one observation, such as n/a for one observation, will cause Stata to read the variable as a string.

If the problem is that you have some observations with non numeric values, like n/a, you should use "destring gdp, replace force." That will replace your string variable gdp with a numeric variable gdp, with missings for observations that were non-numeric.

If the problem is that you have commas or quotes or something, you will need to use the string functions to pull apart the existing string variable and create a new numeric variable. Type "help string" then click on "string functions," for useful examples of commands for this sort of thing.
asquare is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Google Bookmark this Post!Reddit!
Reply With Quote
Old 06-20-2008, 07:06 PM   #3 (permalink)
kkitkat
Within my grasp!
 
kkitkat's Avatar
 
Join Date: Mar 2007
Location: Guelph
Posts: 157
kkitkat is a TestMagic guru. Show your respect!
Also, check whether your GDP variable in Excel is entered as numeric or text. If it is entered as text, Stata will read it as a string variable.
_ _ _ _ SIG _ _ _ _
U of Guelph (Agr. Econ)
kkitkat is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Google Bookmark this Post!Reddit!
Reply With Quote
Old 06-20-2008, 10:53 PM   #4 (permalink)
evilbert
Trying to make mom and pop proud
 
Join Date: Mar 2008
Posts: 17
evilbert just joined TestMagic.
cool thanks for the advice.

it did have missing data which was entered as "#NULL!" so that was causing the problems...what confused me is that the same "#NULL!" wasn't causing any problems for any of the other variables (also non string)

I heard from someone else that apparently if the first row has a non numeric number in it then STATA treats the whole variable as a string.

anyway..thanks for the help..very useful
evilbert is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Google Bookmark this Post!Reddit!
Reply With Quote
Old 06-29-2008, 05:42 PM   #5 (permalink)
econstudent06
Trying to make mom and pop proud
 
Join Date: Jun 2008
Posts: 1
econstudent06 just joined TestMagic.
hi, not sure if your question was already answered or not, but i've come across the problem a number of times in the past also. use the encode statement (encode varlist, gen(newvar)) to "destring" string vars and "encode" them into numeric vars. hope this helps!
econstudent06 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Google Bookmark this Post!Reddit!
Reply With Quote
Old 06-29-2008, 07:10 PM   #6 (permalink)
torts
Trying to make mom and pop proud
 
Join Date: May 2008
Posts: 5
torts just joined TestMagic.
Quote:
Originally Posted by econstudent06 View Post
hi, not sure if your question was already answered or not, but i've come across the problem a number of times in the past also. use the encode statement (encode varlist, gen(newvar)) to "destring" string vars and "encode" them into numeric vars. hope this helps!
I'm pretty sure this is wrong.
torts is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Google Bookmark this Post!Reddit!
Reply With Quote
Old 07-01-2008, 12:35 PM   #7 (permalink)
italos
Within my grasp!
 
italos's Avatar
 
Join Date: Sep 2007
Posts: 339
italos is almost a TestMagic guru.
i suggest you use Stat/Transfer
italos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Google Bookmark this Post!Reddit!
Reply With Quote
Old 07-01-2008, 09:21 PM   #8 (permalink)
asquare
TestMagic Guru
Moderator
 
Join Date: Mar 2006
Location: Ann Arbor
Posts: 1,302
asquare is a member of the TestMagic inner circle.asquare is a member of the TestMagic inner circle.asquare is a member of the TestMagic inner circle.asquare is a member of the TestMagic inner circle.
StatTransfer won't solve the OP's problem. The variable was in fact a string in the original data (it contained the string value "#NULL" for missing observations). So, using StatTransfer to create a Stata dataset would have had exactly the same problem the OP described. In general, I don't think there's any reason to use StatTransfer to go from a .csv or .xls file to Stata. Commands in Stata itself are more than sufficient and are less likely to cause unexpected formatting errors, IMO.
asquare is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Google Bookmark this Post!Reddit!
Reply With Quote
Reply


Thread Tools
Display Modes

What you can do
You cannot post new threads
You cannot post replies
You cannot post attachments
You cannot edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:17 PM.

Contact TestMagic   TestMagic Forums      Archive   

Link to TestMagic   TestMagic Locations   Legal   Privacy

Partner Sites: GMAT Sentence Correction   SAT 2400

Content Relevant URLs by vBSEO 3.0.0
Copyright © 1998-2008 TestMagic
Ad Management by RedTyger

Scroll Up