BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Satori
Quartz | Level 8

Hi

 

I have a .sas7bdat file, I have set up a shared folder and I am using VM virtual box and SAS studio with SAS university edition.

I just want to import this file to the studio and then save it to the shared folder with a different name.

I know very little about SAS.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

you may need to create two libraries like below

 

libname one '¬path1';
libname two'¬path2';


data two.test;
set one.test;
run;

 

 

Thanks,
Jag

View solution in original post

7 REPLIES 7
Jagadishkatam
Amethyst | Level 16

you may need to create two libraries like below

 

libname one '¬path1';
libname two'¬path2';


data two.test;
set one.test;
run;

 

 

Thanks,
Jag
Satori
Quartz | Level 8

What do I put in path 1 and path 2? And what do two.test and one.test refer to?

Can you provide an example?

Jagadishkatam
Amethyst | Level 16

here path 1 represent the path or location of the folder from where you want to import the SAS dataset

path 2 represents the location of the folder where you want to copy the same dataset.

 

So the below will copy the sas dataset from path1 to path2.

 

Here test is the name of the dataset that you want to copy/import from path1 to path2.

 

data two.test;
set one.test;
run;
Thanks,
Jag
Kurt_Bremser
Super User

As a .sas7bdat is already a SAS dataset file, there is no need to import it. You (only) have to put it into a directory where SAS has access to, and define a libname for that directory. After that, the dataset can be used in a set/merge statement, or in a data= option in a proc statement, or in proc sql.

Satori
Quartz | Level 8

How do I define a libname for the directory? And after doing that, what statement should I use?

Kurt_Bremser
Super User

@Satori wrote:

How do I define a libname for the directory? And after doing that, what statement should I use?


STRONGLY recommend that you work through the free online Programming 1 course, as that will guide you through all these questions in a proper, structured way.

The libname and other statements are documented in the Programming Documentation at documentation.sas.com.

Tom
Super User Tom
Super User

@Satori wrote:

Hi

 

I have a .sas7bdat file, I have set up a shared folder and I am using VM virtual box and SAS studio with SAS university edition.

I just want to import this file to the studio and then save it to the shared folder with a different name.

I know very little about SAS.

Thanks!


So if you have setup a shared folder then place the file into that folder (or a subfolder under it).

No matter what path you use to reference the folder from your PC the path that the SAS code (which is running in the VM) must use is /folders/myfolders as explained in the process you just did to setup the shared folder.  You can discover the proper path by finding the file in the SAS/Studio user interface and use the right click mouse button to open the properties for the file.  One of the properties is the path (physical filename) for the file.  So just copy that into your program. 

 

You can reference a SAS dataset in two ways. 

 

The traditional way is to create a libref that points to the folder that contains the file by running a LIBNAME statement. Then you can use the libref along with the member name to refer to the file.

 

The other way is to just use the physical path inside of quotes.

 

So if you have a file name 'mydata.sas7bdat'  (note that the filename MUST be in all lowercase letters as SAS is running in Unix environment where filenames are case sensitive) then you code could look like:

libname mylib '/folders/myfolders';
proc contents data=mylib.mydata; run;

or

proc contents data="/folders/myfolders/mydata.sas7bdat"; run;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 7 replies
  • 50753 views
  • 5 likes
  • 4 in conversation