SAS Programming Professionals,
Did you know that you can physically move a SAS data sets from one directory to another using PROC COPY?
Using PROC COPY obviates your having to move SAS data
sets manually via Windows Explorer or SAS Explorer. For example, let’s move a couple of SAS data
sets from a temporary directory to a permanent directory:
libname templib "c:\temp";
libname mylib "H:\My
Documents\My SAS Files\9.4";
proc copy
in=templib out=mylib
move;
select
air buy;
run;
In this example, we moved
both the AIR and the BUY SAS data sets from the c:\temp
directory to the H:\My Documents\My SAS Files\9.4
directory. Thereafter, if we were to
view the directories in Windows Explorer or SAS Explorer, we would see that
they have indeed been moved.
There are a few other options that you may need to
specify to successfully move SAS data sets that have additional features:
·
ALTER – Is used when you are using the MOVE
option to move files that are have an ALTER password.
·
CLONE – Specifies whether to copy the following
file characteristics to the file that is moved:
o
Input/output
buffer size
o
Data
set compression
o
Whether
free space is reused in compressed data sets
o
Whether
compressed data sets can be accessed by observation number
o
Data
representation
o
Encoding
value
·
CONSTRAINT = YES | NO – Copy existing
integrity constraints when moving a data set.
·
FORCE – Must be used to MOVE a SAS data set that
has an audit trail file.
·
INDEX = YES – Copy indexes for indexed data sets that
are moved.
You would simply specify these options directly after the
MOVE option as in the example, above.
The MOVE option provides a very handy way to have SAS
programmatically move files between various data libraries.
Best
of luck in all your SAS endeavors!
----MMMMIIIIKKKKEEEE
(aka
Michael A. Raithel)
Excerpt from the book:
Did You Know That? Essential Hacks for Clever SAS Programmers
I plan to post each and every one of the hacks in the book to social media on a weekly basis. Please pass them along to colleagues who you know would benefit.
No comments:
Post a Comment