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

st: RE: problem in reading a fixed format data


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: problem in reading a fixed format data
Date   Wed, 13 Nov 2002 18:59:06 -0000

Jiang, Tao
> 
> I have a data set (say, foo.txt) in fixed format, several 
> observations as:
> 
> -10369-13830
>  -1766   944
>   7732  6551
>   6941  3474
>   1164 -3143
>   -272  6880
> 
> I wrote a dictionary file as:
> infile dictionary using foo.txt  {  
>   _column(1) v1 %6.4f                                             
>   _column(7) v2 %6.4f
> }
> 
> when I use infile to input the data via the dictionary 
> file, there is one
> error as: '.-272' cannot be read as a number for v1[6].
> 
> In SAS, I can read into the data without problem, where 
> -272 is translated
> as -.0272.  

Read them in without formats and fix within Stata: 

infix v1 1-6 v2 7-12 using foo.txt

foreach v of var v1 v2 { 
	replace `v' = `v' / 1000 
} 

Nick 
[email protected] 
*
*   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