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

st: RE: import data


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: import data
Date   Tue, 26 Nov 2002 10:17:34 -0000

Hans J. Baumgartner

> is it possible with STATA to import data that is separated
> by semicolon
> AND is also in a fixed format.
>
> Example:
> 161000;Ingolstadt            ;       265;       265;
> 267;       273;
> 162000;München               ;      2005;      1956;
> 1956;      1973;
> ... and so on

Yes. I guess there are several ways to do this.
Here are two.

You could just specify that you have various
-str1- variables in the columns containing the
semicolons and then -drop- those within Stata.

However, what I would do with your example is

. infix str whatever 1-80 using mydata.dat
. split whatever, p(;) destring
. renvars whatever? \ id place d1-d4

That is,

1. read in the data as one string variable

2. use -split- from SSC to split on the semi-colons.

3. use -renvars- from STB-60 to clean up variable
names.

Nick
n.j.cox@durham.ac.uk

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index