Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Difficulty with importing form Excel


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Difficulty with importing form Excel
Date   Fri, 24 May 2013 18:48:59 +0100

-fs- is from SSC. Please remember to explain where user-written
programs you refer to come from.

The " character before `name' looks to be in the wrong place.

Also, avoid using backslashes just before macro references for reasons
documented in
http://www.stata-journal.com/sjpdf.html?articlenum=pr0042 and indeed
in the manual.

I'd try

import excel using "D:\Users\n11094\Desktop\Rahavard Returns\New
folder/`name'", sheet("Sheet1"), clear


Nick
njcoxstata@gmail.com


On 24 May 2013 18:31, Nima Darbari <ramharz@gmail.com> wrote:
> to change their format to .dta. I am trying different variants of the
> code below but I always recieve error messages like 'Invalid 1' and I
> am not even successful with making Stata read even one file. I have
> already spent half of day on it so any comment is highly appreciated.
>
>  set more off
> fs
> foreach name in `r(files)'{
>  import excel using "D:\Users\n11094\Desktop\Rahavard Returns\New
> folder\"`name', sheet("Sheet1"), clear
>  keep A G
>  drop in 1
>  save `name'
>  }
>
> Something else which is strange to me is that apparently there is a
> difference between "Import excl" and "Import excel using" in Stata.
> The first command works well in command window but it doesnt work in
> .do files!
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index