BookmarkSubscribeRSS Feed
eeendless
Calcite | Level 5

I am trying to export SAS data sets as csv files to a shared drive (as opposed to SAS server). Our SAS server allows for exporting files as .xls format to shared drive, via PC File Server. However, this does not work with any other formats, .csv, or .xlsx. I don't exactly know why this is the case, but it is a constraint we now have to work with.

 

I have considered a few options but none of them seems to work for my purpose:

 

1. Exporting as .xls files

This does not work because some of the data sets are larger than Excel can take

 

2. Copy Files task

This would have solved the problem but is not available at my version of SAS EG. Our company is using 7.1 and there is no plan for an upgrade.

 

3. Export csv files to SAS server (it works if I'm exporting to SAS server), and manually move it to shared drive 

I am trying to avoid anything manual, because this is actually part of an automation task that I am building. Plus there are quite a lot of data sets that I am trying to export.

 

Does anyone know how I could go about this? Greatly appreciate any help.

 

Catherine

 

 

8 REPLIES 8
eeendless
Calcite | Level 5

Btw, I also tried this custom copy method as described in here:

 

https://blogs.sas.com/content/sasdummy/2012/12/06/copy-files-in-sas-eg/

 

But I got an error as shown below:

 

ERROR: Target folder (C:\Users\XXXXX\Documents\) does not exist or cannot be accessed on SASApp

 

(SASApp is our SAS server)

TomKari
Onyx | Level 15

A couple of quick questions.

 

What operating system does your SASApp server run?

 

You mention a "shared drive". Can you access this shared drive from SASApp? Can you access it from your PC?

 

Your third option mentions manually moving a file from SASApp to your shared drive. To me, this means that the answer to the previous question is that you can acess the shared drive from SASApp. If not, please explain.

 

Tom

eeendless
Calcite | Level 5

What operating system does your SASApp server run?

I believe it's Windows

 

You mention a "shared drive". Can you access this shared drive from SASApp? Can you access it from your PC?

I can access shared drive from my PC. I don't know how you define "access shared drive from SASApp"... I can open SAS programs on shared drive in SAS, or save SAS programs to shared drive. But if I want to move any generated files between shared drive and SAS server, I have to use FileZilla. And once I'm in the SASApp "directory", I cannot access the shared drive.

 

Your third option mentions manually moving a file from SASApp to your shared drive. To me, this means that the answer to the previous question is that you can access the shared drive from SASApp. If not, please explain.

Like I said earlier, I have to use FileZilla to transfer files between SAS server and shared drives.

Tom
Super User Tom
Super User

@eeendless wrote:

What operating system does your SASApp server run?

I believe it's Windows

 

You mention a "shared drive". Can you access this shared drive from SASApp? Can you access it from your PC?

I can access shared drive from my PC. I don't know how you define "access shared drive from SASApp"... I can open SAS programs on shared drive in SAS, or save SAS programs to shared drive. But if I want to move any generated files between shared drive and SAS server, I have to use FileZilla. And once I'm in the SASApp "directory", I cannot access the shared drive.

 

Your third option mentions manually moving a file from SASApp to your shared drive. To me, this means that the answer to the previous question is that you can access the shared drive from SASApp. If not, please explain.

Like I said earlier, I have to use FileZilla to transfer files between SAS server and shared drives.


If you are not sure what operating system SAS is running on you can just ask SAS to tell you.

509   %put &=sysscp &=syshostinfolong ;
SYSSCP=WIN SYSHOSTINFOLONG=X64_8PRO WIN 6.2.9200  Workstation

A "shared drive" is normally the language the Windows users use to talk about a drive they are accessing from another machine. You might have "mapped" the drive to a drive letter on your PC.  But you should also be able to access it directly using a UNC. Basically the name of the server that is sharing the out the drive and the share name that is using.  So something that looks like \\servername\sharename .  If your SAS session is running on Windows then make sure that the machine it is running on can access the shared drive AND that the userid that is being used to run the SAS process has permission to access the shared drive.  Then you can just write your out files directly to the disk.

data _null_;
  set mydata ;
  file "\\servername\sharename\myfolder\mydata.csv" dsd ;
  put (_all_) (+0);
run;

If SAS is running on a different operating system them ask your support staff to install the proper software for you operating system so that the "shared drive" can be accessed.  So on Unix they might mount the shared drive at some location the Unix filesystem.  Have them explain to you what path on Unix you need to use to access the folder you are trying to write to.

data _null_;
  set mydata ;
  file "/media/servername/sharename/myfolder/mydata.csv" dsd ;
  put (_all_) (+0);
run;
eeendless
Calcite | Level 5

Thanks Tom. This is helpful. I checked the operating system for the SAS server and it is a Linux system. I will work with our system admin to figure out how to access shared drive from that machine. I'm hoping that it is not a control consideration that the shared drive is not accessible from the SAS server.

Reeza
Super User

PC Files server has to do with the file types not the location, AFAIK, but I could be wrong. 

 

How does that process look like to you? Are you doing that via code?

 

If the server has access you should be able to code it to the shared drive, but maybe the code isn't correct? 

 


@eeendless wrote:

I am trying to export SAS data sets as csv files to a shared drive (as opposed to SAS server). Our SAS server allows for exporting files as .xls format to shared drive, via PC File Server. However, this does not work with any other formats, .csv, or .xlsx. I don't exactly know why this is the case, but it is a constraint we now have to work with.

 

I have considered a few options but none of them seems to work for my purpose:

 

1. Exporting as .xls files

This does not work because some of the data sets are larger than Excel can take

 

2. Copy Files task

This would have solved the problem but is not available at my version of SAS EG. Our company is using 7.1 and there is no plan for an upgrade.

 

3. Export csv files to SAS server (it works if I'm exporting to SAS server), and manually move it to shared drive 

I am trying to avoid anything manual, because this is actually part of an automation task that I am building. Plus there are quite a lot of data sets that I am trying to export.

 

Does anyone know how I could go about this? Greatly appreciate any help.

 

Catherine

 

 


 

eeendless
Calcite | Level 5

Yes I tried to use proc export with dbms=csv but it would fail if the outfile is a location on my local machine or shared drive. However with the same statement, if the outfile is a location on the SAS server it would work.

 

I also use server= and port= statement when exporting file to my local machine. It works only with .xls files but not .csv files.

TomKari
Onyx | Level 15

Okay, this is progress. The key thing to understand is that from the SAS perspective, it's running on the SASApp machine, so all references need to be appropriate for that machine. That's why you can't output anything to your machine, for example; SASApp doesn't know anything about it. It would be like when you're using Excel on your machine, trying to save a file to your neighbour's PC; your PC doesn't recognize it.

 

However, @Tom's post above is key. You need to figure out what the shared drive looks like from SASApp, and then there's a good chance you can use SAS to output data directly to it. That's the next piece of information you need.

 

Tom

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 8 replies
  • 9925 views
  • 0 likes
  • 4 in conversation