DATA Step, Macro, Functions and more

What is the fastest way to download sas data to local desktop?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 99
Accepted Solution

What is the fastest way to download sas data to local desktop?

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..


Accepted Solutions
Solution
‎03-14-2017 03:37 AM
Super User
Posts: 3,250

Re: What is the fastest way to download sas data to local desktop?

Posted in reply to afiqcjohari

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


All Replies
Super User
Posts: 19,768

Re: What is the fastest way to download sas data to local desktop?

Posted in reply to afiqcjohari

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. 

Frequent Contributor
Posts: 99

Re: What is the fastest way to download sas data to local desktop?

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?
Super User
Posts: 19,768

Re: What is the fastest way to download sas data to local desktop?

Posted in reply to afiqcjohari

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. 

Frequent Contributor
Posts: 99

Re: What is the fastest way to download sas data to local desktop?

Good explanation. Will bear in mind.
Solution
‎03-14-2017 03:37 AM
Super User
Posts: 3,250

Re: What is the fastest way to download sas data to local desktop?

Posted in reply to afiqcjohari

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;
Frequent Contributor
Posts: 99

Re: What is the fastest way to download sas data to local desktop?

Thanks for the PROC DOWNLOAD tips.
Save me a bunch of time Smiley Happy
Frequent Contributor
Posts: 129

Re: What is the fastest way to download sas data to local desktop?

Posted in reply to afiqcjohari

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 -

Valued Guide
Posts: 505

Re: What is the fastest way to download sas data to local desktop?

I always zip on the server and I like to use
Bruno Mueller's (binary copy with a large chunksize (ie32k)
Frequent Contributor
Posts: 99

Re: What is the fastest way to download sas data to local desktop?

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.
☑ This topic is solved.

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

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