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-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
  • 9 replies
  • 3807 views
  • 1 like
  • 5 in conversation