Henrik Lindegaard wrote:
> Thank you very much Herr Kohler - your second suggestion worked (with a
> small modification).
>
> I just replaced "drop tempvar" with "drop `var'". Whatever the
> difference is - it does what I want.
My mistake. In fact, you do not need the line -drop tempvar- at all. If you
change the line to -drop `var'- you erase the original variables (the one
with the strings) from the dataset. It is up to you whether you want that or
not.
Uli
> Den 29/8-2005, kl. 17.07, skrev Ulrich Kohler:
> > Henrik Lindegaard wrote:
> >> I am trying to insheet a file containing rows of data of the following
> >> format into Stata 9
> >>
> >> "Ringk�bing amt";"�RE-, N�SE- OG HALSAFDELING";"HOLSTEBRO
> >> CENTRALSYGEHUS";"Oto-, rhino-, laryngologi";8,3;9,7;8,2;6,8;6,6;4,8;
> >> "�rhus amt";"KARDIOLOGISK AFDELING B";"SKEJBY
> >> SYGEHUS";"Kardiologi";2,7;8,8;5,7;5,7;7,7;13,4;
> >>
> >> by using
> >>
> >> insheet using "path", delimiter(";") names clear
> >>
> >> but unfortunately the data in columns 5 to 10 are imported as strings
> >> (probably due to the European format), and I cannot figure out how to
> >> change this.
> >
> > If the data stems from Excel you might change the language settings in
> > Excel
> > and export the file again. If this is not an option I would do that
> > within
> > Stata as follows:
> >
> > . foreach var of varlist var5-var10 {
> > . replace `var' = subinstr(`var',",",".",.)
> > . destring `var', gen(`var'n)
> > . drop tempvar
> > . }
> >
> > Explanation: Inside the loop, the first command replaces the "commas"
> > with
> > "dot", the second generates "real" variables from the changed versions.
> > See -help strfun- and -help destring- for details.
> >
> > Uli
> >
> > --
> > [email protected]
> > +49 (030) 25491-361
> >
> > *
> > * 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/
--
[email protected]
+49 (030) 25491-361
*
* 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/