6

Is is possible to save SAS data set (sas7bdat) to a local folder on server? For example c:\Work folder. I know only proc export to csv. Thank you.

  • 1
    Are your working with a local (windows) Version of SAS or serverside, EG etc.? – Jetzler Jun 08 '16 at 13:53
  • By "local" do you mean local to the SAS server or local to you? For SAS to write directly to a directory it will need access to that directory while it is running. If you are using Enterprise Guide there may be some tricks to download a file from the server to your local PC that you can use to download the file that is the SAS dataset. – Tom Jun 09 '16 at 14:41
  • @Tom Hi Tom. I am using EG connected to server. The destination folder is in server too. I need just export my data set (with sas7bdat format) to folder on server. Is it possible? I now the way to do it by proc export csv but I do not need that format. – Donald William Glossfield Jun 14 '16 at 06:40
  • The answer by Reeza is what you want. – Tom Jun 14 '16 at 11:49

3 Answers3

8

Yes, this is what libraries are in SAS. They're essentially folders to store SAS datasets. First create a library reference to the location and then save the dataset to the location.

Libname out '/folders/myfolders/output/';

data out.data_save;
    Set data_to_save;
 Run;
Reeza
  • 20,510
  • 4
  • 21
  • 38
  • for your solution to work, SAS Server will need access to the local drive - which normally is not the case for security reasons. Neither would work if folder is in your local machine – Altons Jun 09 '16 at 14:37
  • @Reeze hi it s working. But is it possible to rename output data set? For example out.dataset15/06/2016? – Donald William Glossfield Jun 15 '16 at 10:08
  • 1
    Yes, just change the name in the DATA statement. But you can't have / in the name, read up on naming rules. – Reeza Jun 15 '16 at 10:14
  • @Reeze this project will run by Stored Process I would not be able to rename smth. But I need to save new data set after every execution in the same folder. – Donald William Glossfield Jun 15 '16 at 10:58
  • You're asking how to generate a unique name for each run of the stored process? IMO that's a different question than what you've phrased above and you should ask a new question. – Reeza Jun 16 '16 at 00:07
0

Depends on how you're connecting to the server and whether you have SAS installled in local machine or not.

If you're using EG you can export the data as csv for example. If what you need is the data as SAS data set then a combination of rsubmit and proc download should do fine.

Here in an example for when you have SAS installed locally:

libname w  "/windows_directory"; 

signon server.port user='your_user' password="your_pwd" ;
rsubmit ;
libname r  "/remote_folder"; 
* Executed in UNIX;

proc download data= r.inServer out= w.inServer; run;
endrsubmit; 
Altons
  • 1,422
  • 3
  • 12
  • 23
0

Check this out, https://stackoverflow.com/a/67914980/8311083.

You can export to sas7bdat as a file to the server.

NiharGht
  • 151
  • 5
  • 10