Hello,
I'm making back up copies of directories on a SAS Share sever from a production SAS Share server. I am able to create a macro to get a list of "DATA" tables and then create a copy of them in a new location. My issue is that some of the locations I'm copying from have views (*.sas7bvew) and index (*.sas7bndx) files and I'm not sure how to make a copy in the new location. In my code I'm looping through a list of libnames and taking the data tables and making a work copy then copying the table to my backup location.
data lib_list ; length lib $10 ; input lib $ ; cards; Lib1 Lib2 Lib3 Lib4 ; run; data _null_ ; set lib_list end = last ; call symput('libname'||trim(left((_n_))), trim(left(lib)) ) ; call symput('nlibs', trim(left(_n_))) ; run ; %macro Get ; %do i = 1 %to &nlibs. ; %let x=Share1 ; options comamid=tcp ; libname &&libname&i. server=x.Shr1 access=readonly ; proc sql ; create table tabs as select * from dictionary.tables where libname = "&&libname&i." and memtype = 'DATA' ; quit ; data _null_ ; set tabs end = last ; call symput('tabname'||trim(left((_n_))), trim(left(memname)) ) ; call symput('ntabs', trim(left(_n_))) ; run ; %do j = 1 %to &ntabs. ; data &&tabname&j. ; set &&libname&i...&&tabname&j. ; run ; %end ; %let w=Share2 ; options comamid=tcp ; libname &&libname&i. server=w.Shr2 ; %do y = 1 %to &ntabs. ; data &&libname&i...&&tabname&y. ; set &&tabname&y. ; run ; %end ; proc datasets lib=work nolist memtype=data ; save lib_list ; quit ; %end ; %mend Get ; options mprint ; %Get ;
Any help would be greatly appreciated.
PROC COPY is not an option for you ?
PROC COPY is not an option for you ?
Hi Michiel,
Will proc copy bring over the views? I didn't think it did, but I could be wrong.
thanks
I ran it again on a specific directory and it looks like it brought everything over.
Server 1 to Work proc copy in=temp out=WORK constraint=yes index=yes ; run; Work to Server 2 proc copy in=work out=temp2 constraint=yes index=yes ; run;
Thank you
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.