BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jerry898969
Pyrite | Level 9

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.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Michiel
Fluorite | Level 6

PROC COPY is not an option for you ?

View solution in original post

3 REPLIES 3
Michiel
Fluorite | Level 6

PROC COPY is not an option for you ?

jerry898969
Pyrite | Level 9

Hi Michiel,

 

Will proc copy bring over the views?  I didn't think it did, but I could be wrong.

 

thanks

jerry898969
Pyrite | Level 9

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3185 views
  • 0 likes
  • 2 in conversation