From: Mike Zdeb on
hi ... I think that this also works
with INFILE and FILE options instead of PIPES
one issue ... it doesn't address the MOVE question, it COPIES
you'd have to delete the original files on your own
(but this is pretty short)


filename in ('k:\epi514\data\*.txt', 'k:\epi514\data\*.html')

data _null_;
length fread fwrite $100.;
infile in filename=fread;
input;
fwrite = catt('z:\test\',scan(fread,-1,'\'));
file out filevar=fwrite;
put _infile_;
run;

filename in clear;

--
Mike Zdeb
U(a)Albany School of Public Health
One University Place
Rensselaer, New York 12144-3456
P/518-402-6479 F/630-604-1475

> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of ash007
> Sent: Sunday, September 27, 2009 6:38 AM
> To: SAS-L(a)LISTSERV.UGA.EDU
> Subject: Move File with Sas pgm
>
> Hello Sas-Users,
>
> How can I move all the file .Txt and the file .Html in a directory
> (without using the X command)? I am working on Window environment.
>
> Thanks.
>
> Ash007.
>
From: Mike Zdeb on
hi (again) ... odd to reply to one's own posting, but ...

I got a couple notes with FDELETE suggestions
this is two steps so you can check to see if the files are copied
before you delete them

(it's now about as long as Randy's solution ... but a different approach)



filename in ('k:\epi514\data\*.txt', 'k:\epi514\data\*.html');

data files_to_delete (keep=hold);
length fread fwrite hold $200.;
retain hold;
infile in filename=fread end=alldone;
if _n_ eq 1 then hold=fread;
if fread ne hold or alldone then do;
output;
hold=fread;
end;
input;
fwrite = catt('z:\test\',scan(fread,-1,'\'));
file xyz filevar=fwrite;
put _infile_;
run;

filename in clear;

data _null_ ;
retain ff "dummy" ;
set files_to_delete;
rc = filename (ff, hold) ;
rc = fdelete (ff) ;
run;



--
Mike Zdeb
U(a)Albany School of Public Health
One University Place
Rensselaer, New York 12144-3456
P/518-402-6479 F/630-604-1475

> hi ... I think that this also works
> with INFILE and FILE options instead of PIPES
> one issue ... it doesn't address the MOVE question, it COPIES
> you'd have to delete the original files on your own
> (but this is pretty short)
>
>
> filename in ('k:\epi514\data\*.txt', 'k:\epi514\data\*.html')
>
> data _null_;
> length fread fwrite $100.;
> infile in filename=fread;
> input;
> fwrite = catt('z:\test\',scan(fread,-1,'\'));
> file out filevar=fwrite;
> put _infile_;
> run;
>
> filename in clear;
>
> --
> Mike Zdeb
> U(a)Albany School of Public Health
> One University Place
> Rensselaer, New York 12144-3456
> P/518-402-6479 F/630-604-1475
>
>> -----Original Message-----
>> From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of ash007
>> Sent: Sunday, September 27, 2009 6:38 AM
>> To: SAS-L(a)LISTSERV.UGA.EDU
>> Subject: Move File with Sas pgm
>>
>> Hello Sas-Users,
>>
>> How can I move all the file .Txt and the file .Html in a directory
>> (without using the X command)? I am working on Window environment.
>>
>> Thanks.
>>
>> Ash007.
>>
>
From: xlr82sas on
On Sep 28, 11:23 am, ms...(a)albany.edu (Mike Zdeb) wrote:
> hi (again) ... odd to reply to one's own posting, but ...
>
> I got a couple notes with FDELETE suggestions
> this is two steps so you can check to see if the files are copied
> before you delete them
>
> (it's now about as long as Randy's solution ... but a different approach)
>
> filename in ('k:\epi514\data\*.txt', 'k:\epi514\data\*.html');
>
> data files_to_delete (keep=hold);
> length fread fwrite hold $200.;
> retain hold;
> infile in filename=fread end=alldone;
> if _n_ eq 1 then hold=fread;
> if fread ne hold or alldone then do;
>    output;
>    hold=fread;
> end;
> input;
> fwrite = catt('z:\test\',scan(fread,-1,'\'));
> file xyz filevar=fwrite;
> put _infile_;
> run;
>
> filename in clear;
>
> data _null_ ;
> retain ff "dummy" ;
> set files_to_delete;
> rc = filename (ff, hold) ;
> rc = fdelete (ff) ;
> run;
>
> --
> Mike Zdeb
> U(a)Albany School of Public Health
> One University Place
> Rensselaer, New York 12144-3456
> P/518-402-6479 F/630-604-1475
>
>
>
> > hi ... I think that this also works
> > with INFILE and FILE options instead of PIPES
> > one issue ... it doesn't address the MOVE question, it COPIES
> > you'd have to delete the original files on your own
> > (but this is pretty short)
>
> > filename in ('k:\epi514\data\*.txt', 'k:\epi514\data\*.html')
>
> > data _null_;
> > length fread fwrite $100.;
> > infile in filename=fread;
> > input;
> > fwrite = catt('z:\test\',scan(fread,-1,'\'));
> > file out filevar=fwrite;
> > put _infile_;
> > run;
>
> > filename in clear;
>
> > --
> > Mike Zdeb
> > U(a)Albany School of Public Health
> > One University Place
> > Rensselaer, New York 12144-3456
> > P/518-402-6479 F/630-604-1475
>
> >> -----Original Message-----
> >> From: SAS(r) Discussion [mailto:SA...(a)LISTSERV.UGA.EDU] On Behalf Of ash007
> >> Sent: Sunday, September 27, 2009 6:38 AM
> >> To: SA...(a)LISTSERV.UGA.EDU
> >> Subject: Move File with Sas pgm
>
> >> Hello Sas-Users,
>
> >> How can I move all the file .Txt and the file .Html in a directory
> >> (without using the X command)? I am working on Window environment.
>
> >> Thanks.
>
> >> Ash007.- Hide quoted text -
>
> - Show quoted text -

If the code is to be cross platform then you should not use platform
specific features?

I often avoid OS solutions in favor of SAS techniques.
From: "Data _null_;" on
You want to be careful using SAS for this. I would not MOVE binary
files and you have to be sure you don't truncate the reacords or
otherwise change the files. Here is a copy a delete as you go
program. It uses a litte trick because SAS wont close a file until it
opens another. I used Mike Zdeb's filename paths.

filename FT15F001 temp;
parmcards;
necessary evil
;;;;
run;

filename in ('.\epi514\data\*.txt', '.\epi514\data\*.html',
"%sysfunc(pathname(FT15F001,F))") lrecl=32767;

data _null_;
length filename lfilename filevar $256;
retain filevar;
lfilename = filename;
infile in eov=eov filename=filename;
input;
if _n_ eq 1 or eov then do;
eov = 0;
filevar = tranwrd(filename,'\data\','\data2\');
if _n_ ne 1 then do;
rc = filename('FT58F001',lfilename);
rc = fdelete('FT58F001');
if rc ne 0 then error;
rc = filename('FT58F001');
end;
end;

file dummy filevar=filevar lrecl=32767;
put _infile_;
run;



On 9/27/09, ash007 <ramsamyashley(a)gmail.com> wrote:
> Hello Sas-Users,
>
> How can I move all the file .Txt and the file .Html in a directory
> (without using the X command)? I am working on Window environment.
>
> Thanks.
>
> Ash007.
>
From: ash007 on
Hi everyone,

Thanks for your reply.

How can I copy a sas Dataset (binary file) without using 'proc copy' ?

Thanks.

ash007.
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Variable reduction method
Next: SUBSTR Madness