|
|
#1 (permalink) |
|
Trying to make mom and pop proud
Join Date: Mar 2008
Posts: 17
![]() |
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 |
|
|
|
|
|
#2 (permalink) |
|
TestMagic Guru
Moderator
Join Date: Mar 2006
Location: Ann Arbor
Posts: 1,302
![]() ![]() ![]() ![]() |
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. |
|
|
|
|
|
#4 (permalink) |
|
Trying to make mom and pop proud
Join Date: Mar 2008
Posts: 17
![]() |
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 |
|
|
|
|
|
#5 (permalink) |
|
Trying to make mom and pop proud
Join Date: Jun 2008
Posts: 1
![]() |
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!
|
|
|
|
|
|
#6 (permalink) | |
|
Trying to make mom and pop proud
Join Date: May 2008
Posts: 5
![]() |
Quote:
|
|
|
|
|
|
|
#7 (permalink) |
|
Within my grasp!
![]() ![]() Join Date: Sep 2007
Posts: 339
![]() |
i suggest you use Stat/Transfer
_ _ _ _ SIG _ _ _ _
GREing again _____________ The Secrets of the Temple:How Admissions are conducted? How to write a good Statement of Purpose(SOP) Facebook TestMagic Econ PhD Forum group |
|
|
|
|
|
#8 (permalink) |
|
TestMagic Guru
Moderator
Join Date: Mar 2006
Location: Ann Arbor
Posts: 1,302
![]() ![]() ![]() ![]() |
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.
|
|
|
|
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