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

I have this routine whereby I need to analyze data from the server.

 

However, I find that doing the analysis locally is much more pleasant than using the server.

 

What's the best way to download the a sas data to a local folder?

 

*connection to server;
rsubmit;
 proc sql;
   create table tolocal as 
   select * from servertable
   where <conditions>
 ;quit;
endrsubmit;
* tolocal is now in Rwork;

*define local folder on desktop;
libname mylocal "C:\Users\Working folder";

*download data to mylocal;
data mylocal.tolocal; set rwork.tolocal;run;

Is it possible to do everything within rsubmit?

It seems that I can't define the local folder within rsubmit..

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Since you have both PC SAS and server SAS you could download your SAS data using PROC DOWNLOAD which has the smarts to know about your local LIBNAMEs:

 

rsubmit;

proc download data = tolocal
              out = mylocal.tolocal;
run;

endrsubmit;

View solution in original post

9 REPLIES 9
Reeza
Super User

It depends. Sometimes the desktop and server have different modules licensed. For example we had SAS IML on desktops but not server... not sure why. Most things should be able to run on the server and should be faster since they're typically much faster machines.  Sometimes network speed can mess that up though. It does require a small shift in how you work but once you figure it out it's significantly faster. 

 

No you can't define a local folder on the server, you need to give it a location the server has access to, somewhere on the server or a shared drive. 

afiqcjohari
Quartz | Level 8
I concur about the different modules. Though for this exercise, I've no need to worry about it... Yet.

Anyways, is proc download a better alternative to data;set;run?
Reeza
Super User

Yes, because data steps read each line and proc download or even proc copy can move the data in blocks. 

 

A datastep could create new variables or change the dataset somehow. If none of this is occurring a different method is more efficient. 

afiqcjohari
Quartz | Level 8
Good explanation. Will bear in mind.
SASKiwi
PROC Star

Since you have both PC SAS and server SAS you could download your SAS data using PROC DOWNLOAD which has the smarts to know about your local LIBNAMEs:

 

rsubmit;

proc download data = tolocal
              out = mylocal.tolocal;
run;

endrsubmit;
afiqcjohari
Quartz | Level 8
Thanks for the PROC DOWNLOAD tips.
Save me a bunch of time 🙂
Oligolas
Barite | Level 11

Hi,

 

on SAS/CONNECT non licensed Windows machines, one could use robocopy to perform the task.

Robocopy has the big advantage that it creates the output folder by its own and can also copy subdirectory files without further specifying them.

Consult robocopy /? in the command line for more details.

libname inLib "C:\TEMP\input Lib Folder";
libname outLib "C:\TEMP\output Lib Folder";
x "robocopy ""%sysfunc(pathname(inLib))"" ""%sysfunc(pathname(outLib))"" *.sas7bdat *.png /MIR";
/*
   interesting parameters:
   /PURGE
   /XF
   /XD
   /LOG:
*/

 

I would advise to use the compress option on SAS datasets whenever possible if you intend to regularly transfer a big amount of files over your network.

________________________

- Cheers -

rogerjdeangelis
Barite | Level 11
I always zip on the server and I like to use
Bruno Mueller's (binary copy with a large chunksize (ie32k)
afiqcjohari
Quartz | Level 8
I'm transferring file from the server to my local desktop. I don't think I can automate using robocopy as I need to open the cmd line.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 4611 views
  • 1 like
  • 5 in conversation