# Re: st: Re:Reading data into Stata

 From "Victor M. Zammit" To Subject Re: st: Re:Reading data into Stata Date Fri, 10 Oct 2008 11:38:58 +0200

```Dear Statalist,
thanks for the answers.I have circumvented going through all the some 4000
rows ,by :

drop _all
input str15 s1 str15 s2 str15 s3 str15 s4 str15 s5 str15 s6 str15 s7 str5
Party Year District  str6 Won

Smith White ,John  (James)  Dem  1920  6  Won

Black , Tom  k/a Tommy  Lib 1932 6

Fish , James Cons  1939 2

.......................................

.........................................

Brown Balck, Sam   Dem 2002  4  Won

end

di _N

local i = 1

while `i'<= 7 {

capture replace s`i'="" if s`i'==")" | s`i'=="(" | s`i'=="K" | s`i'=="k" |
s`i'=="A" | s`i'=="a" | s`i'=="/" | s`i'=="'" | s`i'=="[" | s`i'=="]"

local i = `i'+1

}

di _N

gen n = _n

local no = _N

di `no'

sort n

save s2s7,replace

Then I run the same program ,but with     "str15  s7"  missing ,  ie

drop _all
input str15 s1 str15 s2 str15 s3 str15 s4 str15 s5 str15 s6 str15 s7 str5
Party Year District  str6 Won

Smith White ,John  (James)  Dem  1920  6  Won

Black , Tom  k/a Tommy  Lib 1932 6

Fish , James Cons  1939 2

.......................................

.........................................

Brown Balck, Sam   Dem 2002  4  Won

end

di _N

local i = 1

while `i'<= 7 {

capture replace s`i'="" if s`i'==")" | s`i'=="(" | s`i'=="K" | s`i'=="k" |
s`i'=="A" | s`i'=="a" | s`i'=="/" | s`i'=="'" | s`i'=="[" | s`i'=="]"

local i = `i'+1

}

di _N

gen n = _n + `no'

local no = _N + `no'

di `no'

sort n

save s2s6,replace

...... and continue removing one string at a time until no new data is read
by Stata. Then merge s2s7,s2s6, ..... s2s3 .

This requires some work  ,but it is the most efficient way that  I know of.

Victor Michael  Zammit

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```