2

I am using SAS Studio(completely browser based). I need to export a dataset to my local machine in the .sas7bdat file format. I think it should be something like PROC EXPORT data = sqrtReg2 outfile = "C:\Documents\SAS\Target_Wins.sas7bdat";. But that returns the error ERROR: Unable to determine datasource type. Please use the DBMS= option.. But the DBMS option only allows for CSV, tab and DLM. How do I export this data set to my local machine in the .sas7bdat file format?

user18101
  • 626
  • 3
  • 13
  • 22

4 Answers4

3

With the SAS University Edition you can setup shared folders in the virtual machine where SAS runs that are mapped to actual folders on your real machine.

For example you might have mapped C:\Documents\SAS\ to /folders/myfolders. You cannot write to other locations on your real machine that are not mapped so that the virtual machine can see them. Check the documentation for exact details of getting the folders mapped.

The normal way to have SAS place a dataset then is to create a libref that points to the folder and then use a two level name when referencing the data set. You could create a libref named OUT for example:

 libname out '/folders/myfolders/';
 data out.target_wins; 
   set sqrtReg2;
 run;

But you can also just refer to the file directly without first creating a libref.

 data '/folders/myfolders/target_wins'; 
   set sqrtReg2;
 run;

Note that since SAS is actually running in Unix you cannot use CamelCaseFileNames for your SAS datasets. The files will always be in all lowercase letters.

Tom
  • 47,574
  • 2
  • 16
  • 29
  • Just a note that the myfolders shared folders needs to be under ..\SASUniversityEdition\myfolders for the shared folder to be set up properly. Additionally you can set up other locations if desired. – Reeza Jul 11 '16 at 01:06
  • for this to work `'folders/myfolders/;` should be where the data sets exists in the file system in SAS Studio. Then you can right click and download – user18101 Jul 11 '16 at 01:32
  • @user18101 once it's saved in the myfolders location it's on your local harddrive, wherever you set up the myfolders at installation. You can navigate there and move it as desired. If you right click and view properties it will show you the path. – Reeza Jul 11 '16 at 06:10
1

None of the answers worked for me. Maybe because after April 2021, they have made changes to the platform(University). So, after a lot a time searching, I found what I needed.

You can easily export the sas dataset to csv, xslx, by just right clicking on the dataset and selecting export as csv, xlsx, etc. For exporting to sas7bdat file, do:

  1. Create your dataset, I am creating from csv, so create a program1(.sas) to first convert csv to sas dataset.
proc import file="/home/u123/mydata.csv"
    out=work.mydata
    dbms=csv
    replace;
run;

This will create your sas dataset.

  1. IMP Go to "Libraries" at the right bottom, and hit "My Libraries" -> New Library -> Name it(eg - test), give path(eg - /home/u123/sasuser.v94) Check library creation, and HIT "Refresh Library Session" on right pane, don't refresh the page.

  2. Now create a separate program2(.sas), to export the dataset to .sas7dbat file.

PROC COPY IN=WORK OUT=test;
SELECT mydata;
run;
quit

This will create a .sas7bdat file in your directory, with same name as your dataset.

These exact steps worked out for me.

NiharGht
  • 151
  • 5
  • 10
  • I don't understand how this answer about XLSX files and CSV files has anything to do with the original question about sas7bdat files. But it is all moot now as SAS University Edition is no more. – Tom Mar 05 '22 at 03:55
  • @Tom because the op was asking for exporting as sas7bdat file from the existing dataset, and with university, I was unable to do so without the above mentioned process. Hence, with xlsx/csv I gave the process. – NiharGht Mar 05 '22 at 08:54
0

It won't work for 2 reasons.

  1. You can't export a SAS dataset to a SAS dataset (.sas7bdat) - Proc Export will export to excel, csv, etc but not to a .sas7bdat.
  2. you're running SAS Studio from within a Virtual Machine that uses Linux as OS so path to create an external file is incorrect. You haven't hit this error but you will once you use the right filetype.

When you installed SAS Studio you should have created a shared folder. This folder is accessed from within SAS Studio as /folders/myfolders/filename.

So your code should looks like this:

PROC EXPORT data = sqrtReg2 
            outfile = "/folders/myfolders/Target_Wins.csv";
run;

From Windows the path to this shared folder will depend upon where you installed your VM.

Option 2

If what you need is the dataset then try the following code:

libname out "/folders/myfolders/";

proc copy in=work out=out;
 select sqrtReg2 ;
run;

Again, table will be in your shared folder which is accesible from Windows.

Altons
  • 1,422
  • 3
  • 12
  • 23
  • How am I able to download the .sas file then? I believe you but why one file and not the other? – user18101 Jul 10 '16 at 20:04
  • It's a terminology difference. You write a SAS dataset to a library location you don't export it. Export assumes changing the file type. – Reeza Jul 11 '16 at 01:07
  • @user18101 - a .sas file is a scripting file, .sas7bdat is your table. See my update re downloading your dataset, assuming you're working locally and not running SAS Studio from a cloud service (ie AWS). – Altons Jul 11 '16 at 06:40
0

I used just like option 2 in the above answer. I need to export my polygon data from SAS Studio in my virtual machine so that i can import it to my Visual Analytics. and it worked just fine.

libname out "/folders/myfolders/";

proc copy in=work out=out;
 select my_map;
run;