Help using Base SAS procedures

Copy or move a table between libraries

Accepted Solution Solved
Reply
Contributor
Posts: 58
Accepted Solution

Copy or move a table between libraries

Hi, I need to know how to move a table in a library in a server to another library in another server.

I have a table in the library Work in the server SASMain and I need to copy or move it to the library Work but in another server named PSASD01. How could I do that?

I was looking for a possible answer but I found this kind of code:

LIBNAME lib1 'SAS-data-library';

LIBNAME lib2 'SAS-data-library';

PROC DATASETS;

COPY IN=lib1 OUT=lib2 MOVE;

SELECT member1 member2;

RUN;

where 'SAS-data-library' is replaced by a path in the pc as 'C:\temp', but in my case is not a path in my computer but it's a libray in a server. Thanks in advance!


Accepted Solutions
Solution
‎10-03-2017 07:59 AM
Super Contributor
Posts: 253

Re: Copy or move a table between libraries

Can you access that in windows explorer?  IE, I might have a NAS store in:

//mycompanysnas/sasfiles/myfolder/projectname/

that I could just open in Windows Explorer.  If I can do that (on the machine running SAS, whether that's your local server/installation or you have a windows or whatever server running SAS that you use EG to connect to), then you can just write the libname that way:

libname servlib "//mycompanysnas/sasfiles/myfolder/projectname/";

Then you can use it as a normal library - proc copy to your heart's content.

If you can't access it directly, you'll want to provide more information - are you running this locally or on a SAS Server; does this other server also have a SAS server running; are you using SAS CONNECT, Enterprise Guide, etc.?

View solution in original post


All Replies
Solution
‎10-03-2017 07:59 AM
Super Contributor
Posts: 253

Re: Copy or move a table between libraries

Can you access that in windows explorer?  IE, I might have a NAS store in:

//mycompanysnas/sasfiles/myfolder/projectname/

that I could just open in Windows Explorer.  If I can do that (on the machine running SAS, whether that's your local server/installation or you have a windows or whatever server running SAS that you use EG to connect to), then you can just write the libname that way:

libname servlib "//mycompanysnas/sasfiles/myfolder/projectname/";

Then you can use it as a normal library - proc copy to your heart's content.

If you can't access it directly, you'll want to provide more information - are you running this locally or on a SAS Server; does this other server also have a SAS server running; are you using SAS CONNECT, Enterprise Guide, etc.?

Contributor
Posts: 58

Re: Copy or move a table between libraries

Posted in reply to snoopy369

I've asked for the path of the servers.

Just in case, I'm running on a SAS Server that is the same that SASMain. I use Enterprise Guide.

Super User
Posts: 19,869

Re: Copy or move a table between libraries

Can you access SAS Foundation or Base SAS? It's easier there....

Contributor
Posts: 58

Re: Copy or move a table between libraries

Hi Reeza, in the lower part, I suppose is the status bar or something like that appears: "

, connected to PAMLP01:8561/Foundation". Also, when you check the SASMain properties, PALMP01 appears as the host name (SASMain is the server from where I want to copy the table).

Community Manager
Posts: 2,955

Re: Copy or move a table between libraries

If you are using SAS Enterprise Guide, you can use Data->Download SAS Data Sets and then Data->Upload SAS Data Sets to copy the data from your source library to your PC, then from your PC to your target library.  That is two hops, but the file transfer is pretty fast as long as you have a good network connection.

Chris

Regular Contributor
Posts: 151

Re: Copy or move a table between libraries

Posted in reply to ChrisHemedinger

Hi Chris

am trying to move tables from one libarary to another library in SAS 9.2 (solaris 5.10)

How can i do that,please can you give the steps

I would really appreciate for all your help

Thank you

Community Manager
Posts: 2,955

Re: Copy or move a table between libraries

Posted in reply to sasprofile

If both of your SAS libraries are on the same SAS session, you can use PROC COPY or PROC DATASETS with the COPY statement.

Chris

Regular Contributor
Posts: 151

Re: Copy or move a table between libraries

Posted in reply to ChrisHemedinger

both are in same sas session i tried this but its not moving any tables

here QOC11 and POC12 are my two libaries
and qoc and tlib12 are librefs

I tried to move one table AVG_DIFFS_FROM_TARGETS shown below

LIBNAME qoc 'QOC11';

LIBNAME tlib12 'POC12';

PROC COPY;

COPY IN=qoc OUT=tlib12 MOVE;

SELECT AVG_DIFFS_FROM_TARGETS;

RUN;

Super User
Posts: 19,869

Re: Copy or move a table between libraries

Posted in reply to sasprofile

You don't need librefs for libraries. Put the library names directly into proc copy or datasets.

PROC datasets library=work nodetails nolist;

COPY IN=QOC12 OUT=POC12;

SELECT AVG_DIFFS_FROM_TARGETS;

RUN; QUIT;

Regular Contributor
Posts: 151

Re: Copy or move a table between libraries

Reeza,

Thanks alot for your prompt reply

I got below error when i ran the above

COPY IN=QOC12 OUT=Testlib;

         __

         22

         76

                       

NOTE: Enter RUN; to continue or QUIT; to end the procedure.

ERROR 22-322: Syntax error, expecting one of the following: ;, ALTER, CLONE, CONSTRAINT, DATECOPY, FORCE, IN, INDD, INDEX, INLIB,

              MEMTYPE, MOVE, MT, MTYPE, NOCLONE, OUT, OUTDD, OUTLIB, PROTECT, PW. 

ERROR 76-322: Syntax error, statement will be ignored.

Super User
Posts: 19,869

Re: Copy or move a table between libraries

Posted in reply to sasprofile

Your proc copy is incorrect, the in/out are on the same line as proc copy. Or use proc datasets.

Both of the ones below work.

Also, in the future please ask a new question rather than post in a question that is 2 years old.

libname test '/folders/myfolders';

proc copy library=work;

copy out=test in=sashelp;

select class cars heart;

run;quit;

proc copy out=test in=sashelp;

select air;

run;quit;

Super User
Posts: 5,438

Re: Copy or move a table between libraries

Copying data between servers, and especially to a specific work-library, doesn't sound like a best practice.

If this is one time shot, just copy in a windows explorer, or whatever tool that is available to you.

What will you do with the table in the other work? Are you using EG in both these servers? Can't get the full picture here...

Data never sleeps
☑ This topic is solved.

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

Discussion stats
  • 12 replies
  • 8541 views
  • 0 likes
  • 6 in conversation