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

st: RE: reading dataypse in insheet

To   <>
Subject   st: RE: reading dataypse in insheet
From   "Nick Cox" <>
Date   Thu, 6 Jun 2002 12:10:45 +0100
Importance   Normal
In-reply-to   <>

R. Prabhakar 

> i was wondering what is the procedure that stata using in descding
> datatypes in the insheet command. does it do it based on the datatype of
> the first row of data? if so, then what does it do when the data in teh
> first row is missing?

-insheet- is inclined to treat variables
as numeric unless they are "obviously" string. 
But one non-numeric value is enough to make 
a variable "obviously" string. A single period 
may, however, be interpreted as numeric, because 
that indicates numeric missing. 

I created this little test.dat 


and used -insheet-. 

-v1- with values 1,5,10,15 is treated as numeric. 
-v2- with values .,6,11,16 ditto. 

No surprises so far. 

-v3- with values "3",7,12,17 is also treated 
as numeric. In effect, the " " are ignored. 
Clearly, -insheet- looks beyond the first 
data row. 

Similarly, -v4- with values "4","8","13","18"
is treated as numeric. Even the " " on every 
value do not make this a string variable. 

In contrast, -v5- with a single non-numeric
value, the "toad" lurking at the bottom, 
is treated as string. Clearly, -insheet- 
can change its mind even at the last row. 

This sensitivity clashes, for example, with
the habit of many spreadsheet users of 
interpolating lines of text within their
data files. But treating such a variable as string is the 
only way that Stata can do justice to 
what you input. Stata is not in the business of 
guessing what the data "should" be. 

There is, I guess, a question behind your 
question. The FAQs at

may help. Start with

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index