Help using Base SAS procedures

Assign different files into one libname with different location?

Accepted Solution Solved
Reply
Super Contributor
Posts: 398
Accepted Solution

Assign different files into one libname with different location?

Hi all:

 

I have codes below.  I would like to assign Surv10 in SURV folder, Pneulab in LAB folder and Vax10 in VAX folder into one new folder RDB.   I am curious if there is a better way to do it.  Thanks.

 

libname RDBlab "Pathway\data\lab";
libname RDBsurv "Pathway\data\surv";
libname RDBvax "Pathway\data\vax";
libname RDB "Pathway\data";

data RDB.SURV10; set RDBsurv.SURV10; run;
data RDB.PNEULAB; set RDBlab.PNEULAB; run;
data RDB.VAX10; set RDBvax.VAX10; run;

Accepted Solutions
Solution
a week ago
Super User
Posts: 10,784

Re: Assign different files into one libname with different location?

You can refer to these table if their table name is unique.

 

libname RDB ( "Pathway\data\lab" "Pathway\data\surv" "Pathway\data\vax" );

data x;
 set RDB.SURV10;
run;

View solution in original post


All Replies
Super User
Posts: 23,754

Re: Assign different files into one libname with different location?

PROC DATASETS or PROC COPY.
Super Contributor
Posts: 398

Re: Assign different files into one libname with different location?

Hi Reeza:

 

I used PROC COPY, but really didn't see any simpler than mines.  

 

proc copy out=RDB in=RDBlab memtype=data;
	select PNEULAB;
run;

proc copy out=RDB in=RDBsurv memtype=data;
	select SURV10;
run;

proc copy out=RDB in=RDBvax memtype=data;
	select VAX10;
run;
Super User
Posts: 23,754

Re: Assign different files into one libname with different location?

@ybz12003 when you use a data step SAS copies the data line by line, in case you have any calculations/manipulations. 

However, when you use PROC COPY, it copies the data over in blocks instead of a line at a time. For a large data set this has significant time savings, but for smaller tables you may not see an improvement. 

 

I don't think this is any simpler but it seems a bit more clean to me. 

 

proc datasets lib=work;
copy in=sashelp out=work; *from sashelp to work;
select class;
copy in=sasuser out=work; *from sasuser to work;
select funcs;
run;quit;
Super Contributor
Posts: 398

Re: Assign different files into one libname with different location?

Oh, I don't know that.  Thanks for the clarification.

Solution
a week ago
Super User
Posts: 10,784

Re: Assign different files into one libname with different location?

You can refer to these table if their table name is unique.

 

libname RDB ( "Pathway\data\lab" "Pathway\data\surv" "Pathway\data\vax" );

data x;
 set RDB.SURV10;
run;
Super Contributor
Posts: 398

Re: Assign different files into one libname with different location?

Thanks, Kshap.  That's awesome! Smiley Happy

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 107 views
  • 0 likes
  • 3 in conversation