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

st: RE: Re: no observations


From   "Mihalka, Michael" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: no observations
Date   Wed, 19 May 2004 00:34:21 +0200

This problem often arrises when there are empty cells produced by excel. As indicated by others, the variable is interepreted as string. You can simply convert the variable into numeric by using the real command.
 
Alternatively, you can replace the empty cell as a period (.) which is interpreted as a missing value by stata.
 
BTW, why not simply save the excel file as a tab-delimited ASCII file.
 
Cheers!
Michael
 
-----Original Message----- 
From: Roger Newson [mailto:[email protected]] 
Sent: Tue 5/18/2004 10:19 PM 
To: [email protected] 
Cc: 
Subject: st: Re: no observations



	At 16:02 18/05/04 -0400, cheryl wrote:
	
	>Hi,
	>
	>Hoping someone can help with the following problem:
	>Followed these directions to get my data into Stata
	>1. How do I get information from Excel into Stata?
	>Using your Windows or Macintosh computer,
	>Start Excel.
	>Enter data in rows and columns OR read in a previously-saved file.
	>Highlight the data of interest, then pull down Edit and choose
	>Copy.
	>Start Stata and enter the data editor (type edit once Stata is
	>running).
	>Paste data into editor by pulling down Edit and choosing Paste
	>
	>Minor problem that saving is not an option from the pull-down
	>menu, so I clicked on the disk.
	>
	>Now here is the real problem:
	>  . edit
	>  (32 vars, 50 obs pasted into editor)
	>  - preserve
	>
	>  . save "C:\Documents and Settings\Cheryl Spinner\Cheryl Spinner\My
	>  Documents\Columbia\Thesis\usnwr3.dta"
	>file C:\Documents and Settings\Cheryl Spinner\Cheryl Spinner\My
	>Documents\Columbia\Thesis\usnwr3.dta saved
	>  . reg overallscore endowment
	>  no observations
	>  r(2000);
	>
	>If 50 obs are pasted in, how come there are no observations?
	>All my data except for headers are numeric values.
	>
	>What am I doing wrong and what do I need to do?
	
	I suspect that Stata thinks that either overallscore or endowment is a
	string variable. Before typing reg, type
	
	describe
	
	and Stata will list the variables it thinks it has. If the type of a
	variable begins with "str", then Stata has read it as a string variable,
	and not a numeric variable. This sometimes happens if you have typed in
	non-numeric characters in a numeric field.
	
	Hope this helps.
	
	Roger
	
	
	--
	Roger Newson
	Lecturer in Medical Statistics
	Department of Public Health Sciences
	King's College London
	5th Floor, Capital House
	42 Weston Street
	London SE1 3QD
	United Kingdom
	
	Tel: 020 7848 6648 International +44 20 7848 6648
	Fax: 020 7848 6620 International +44 20 7848 6620
	   or 020 7848 6605 International +44 20 7848 6605
	Email: [email protected]
	Website: http://www.kcl-phs.org.uk/rogernewson
	
	Opinions expressed are those of the author, not the institution.
	
	*
	*   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