From: Paul on
Is there a way to make a copy of an external files from SAS (without
using SYSTEM or X)?

I want to "proc import" an excel file even if the user already has it
open. The idea is to first copy it to C:\temp (OK not very portable...)
and then "proc import" the copy. I can do it with "system" and the
noxwait option, but that pops up that ugly window, very distracting. I
see I can do things like
rc=rename('d:\temp','d:\testfile','file');
but is there an equivalent for "copy"? I can't find it anywhere!

Any help would be greatly appreciated!

Paul

From: Arthur Tabachneck on
Paul,

Please provide more details regarding what you are trying to accomplish
and why you haven't been successful.

I ran the following two procs with the user (me) having already opened the
spreadsheet in Excel:

PROC IMPORT OUT= WORK.TEST1
DATAFILE= "c:\sample.xls"
DBMS=EXCEL2000 REPLACE;
GETNAMES=YES;
RUN;
PROC IMPORT OUT= WORK.TEST2
DATAFILE= "c:\sample.xls"
DBMS=EXCEL2000 REPLACE;
GETNAMES=YES;
RUN;

Even with c:\sample.xls open in Excel, both proc imports worked.

Art
-------------
On Sat, 25 Nov 2006 14:35:30 -0800, Paul <vanwamelen(a)GMAIL.COM> wrote:

>Is there a way to make a copy of an external files from SAS (without
>using SYSTEM or X)?
>
>I want to "proc import" an excel file even if the user already has it
>open. The idea is to first copy it to C:\temp (OK not very portable...)
>and then "proc import" the copy. I can do it with "system" and the
>noxwait option, but that pops up that ugly window, very distracting. I
>see I can do things like
> rc=rename('d:\temp','d:\testfile','file');
>but is there an equivalent for "copy"? I can't find it anywhere!
>
>Any help would be greatly appreciated!
>
>Paul
From: Paul on
Two things:
1) I have a particular excel file that, indeed, does get read by proc
import whether I have it open or not, but if I have it open at least
one of the columns don't get recognized as numeric. It's a bit weird
but it does happen consistently. Also everything I've found on proc
import of excel files warn that the file should not be open in excel.
I've also had reports from other people that if someone else has the
file open proc import fails. I have no first hand experience of this
though.
2) I found I way to cleanly copy the file:
systask command "copy &filename &tmpfilename" wait;

Thanks for your time!

Paul

Arthur Tabachneck wrote:
> Paul,
>
> Please provide more details regarding what you are trying to accomplish
> and why you haven't been successful.
>
> I ran the following two procs with the user (me) having already opened the
> spreadsheet in Excel:
>
> PROC IMPORT OUT= WORK.TEST1
> DATAFILE= "c:\sample.xls"
> DBMS=EXCEL2000 REPLACE;
> GETNAMES=YES;
> RUN;
> PROC IMPORT OUT= WORK.TEST2
> DATAFILE= "c:\sample.xls"
> DBMS=EXCEL2000 REPLACE;
> GETNAMES=YES;
> RUN;
>
> Even with c:\sample.xls open in Excel, both proc imports worked.
>
> Art
> -------------
> On Sat, 25 Nov 2006 14:35:30 -0800, Paul <vanwamelen(a)GMAIL.COM> wrote:
>
> >Is there a way to make a copy of an external files from SAS (without
> >using SYSTEM or X)?
> >
> >I want to "proc import" an excel file even if the user already has it
> >open. The idea is to first copy it to C:\temp (OK not very portable...)
> >and then "proc import" the copy. I can do it with "system" and the
> >noxwait option, but that pops up that ugly window, very distracting. I
> >see I can do things like
> > rc=rename('d:\temp','d:\testfile','file');
> >but is there an equivalent for "copy"? I can't find it anywhere!
> >
> >Any help would be greatly appreciated!
> >
> >Paul

From: Arthur Tabachneck on
Paul,

I am far from an expert concerning the relationships between proc import
and Excel.

That said, based on your response I just discovered something interesting
about the relationship between proc import and Excel. I can only test this
with myself as both users, but if I open Excel and start to edit the file,
then leave it open (unsaved) and try to import the file with proc import,
proc import reads the file as if the unsaved changes had been saved.

In short, I agree, don't try to import open Excel files.

Art
-------------
On Sun, 26 Nov 2006 10:22:56 -0800, Paul <vanwamelen(a)GMAIL.COM> wrote:

>Two things:
>1) I have a particular excel file that, indeed, does get read by proc
>import whether I have it open or not, but if I have it open at least
>one of the columns don't get recognized as numeric. It's a bit weird
>but it does happen consistently. Also everything I've found on proc
>import of excel files warn that the file should not be open in excel.
>I've also had reports from other people that if someone else has the
>file open proc import fails. I have no first hand experience of this
>though.
>2) I found I way to cleanly copy the file:
> systask command "copy &filename &tmpfilename" wait;
>
>Thanks for your time!
>
>Paul
>
>Arthur Tabachneck wrote:
>> Paul,
>>
>> Please provide more details regarding what you are trying to accomplish
>> and why you haven't been successful.
>>
>> I ran the following two procs with the user (me) having already opened
the
>> spreadsheet in Excel:
>>
>> PROC IMPORT OUT= WORK.TEST1
>> DATAFILE= "c:\sample.xls"
>> DBMS=EXCEL2000 REPLACE;
>> GETNAMES=YES;
>> RUN;
>> PROC IMPORT OUT= WORK.TEST2
>> DATAFILE= "c:\sample.xls"
>> DBMS=EXCEL2000 REPLACE;
>> GETNAMES=YES;
>> RUN;
>>
>> Even with c:\sample.xls open in Excel, both proc imports worked.
>>
>> Art
>> -------------
>> On Sat, 25 Nov 2006 14:35:30 -0800, Paul <vanwamelen(a)GMAIL.COM> wrote:
>>
>> >Is there a way to make a copy of an external files from SAS (without
>> >using SYSTEM or X)?
>> >
>> >I want to "proc import" an excel file even if the user already has it
>> >open. The idea is to first copy it to C:\temp (OK not very portable...)
>> >and then "proc import" the copy. I can do it with "system" and the
>> >noxwait option, but that pops up that ugly window, very distracting. I
>> >see I can do things like
>> > rc=rename('d:\temp','d:\testfile','file');
>> >but is there an equivalent for "copy"? I can't find it anywhere!
>> >
>> >Any help would be greatly appreciated!
>> >
>> >Paul
From: "Choate, Paul on
Paul -

I'm afraid this doesn't work for files that are open, but it does create
a binary "copy of an external file from SAS (without using SYSTEM or
X)":

data _null_;
infile 'old.xls' recfm=n;
file 'new.xls' recfm=n;
input byte $char1. @;
put byte $char1. @;
run;

hth

Paul Choate
DDS Data Extraction
(916) 654-2160

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of
Paul
Sent: Saturday, November 25, 2006 2:36 PM
To: SAS-L(a)LISTSERV.UGA.EDU
Subject: copy external file

Is there a way to make a copy of an external files from SAS (without
using SYSTEM or X)?

I want to "proc import" an excel file even if the user already has it
open. The idea is to first copy it to C:\temp (OK not very portable...)
and then "proc import" the copy. I can do it with "system" and the
noxwait option, but that pops up that ugly window, very distracting. I
see I can do things like
rc=rename('d:\temp','d:\testfile','file');
but is there an equivalent for "copy"? I can't find it anywhere!

Any help would be greatly appreciated!

Paul
 |  Next  |  Last
Pages: 1 2
Prev: Error SAS to ORACLE
Next: Questions about SAS DDE,