Write and run SAS programs in your web browser

How do I import ".sas7bdat" file by creating a library in SAS University Edition

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

How do I import ".sas7bdat" file by creating a library in SAS University Edition

Hello everyone, SAS beginner here. Using SAS University Edition from a Mac. I am trying to import a file "inventory.sas7bdat" by creating a library. I have used this piece of code in windows while using SAS from server. But not being able to make it work here.

Here's my code:

 

LIBNAME abcd "/folders/myfolders";
data abcd.inventory;
infile "/folders/myfolders/inventory.sas7bdat";
proc print data = abcd.inventory;

 

I am getting this error message -

 

58 infile "/folders/myfolders/inventory.sas7bdat";
 
ERROR: File is in use, /folders/myfolders/inventory.sas7bdat.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set ABCD.INVENTORY may be incomplete. When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set ABCD.INVENTORY was not replaced because this step was stopped.
 
For your information:
- I am using virtual box VM
-i have checked the shared folder and the data file is inside the folder

Screen Shot 2016-10-13 at 8.55.13 PM.pngScreen Shot 2016-10-13 at 9.00.42 PM.png

Accepted Solutions
Solution
‎10-14-2016 01:39 PM
Super User
Posts: 19,100

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

You don't import a sas file per se. 

 

You reference it using libname.data_name. 

 

Libname abcd ... 

 

Data inventory; * dataset to be created;

set abcd.inventory; *data being used in data step;

run; 

View solution in original post


All Replies
Solution
‎10-14-2016 01:39 PM
Super User
Posts: 19,100

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

You don't import a sas file per se. 

 

You reference it using libname.data_name. 

 

Libname abcd ... 

 

Data inventory; * dataset to be created;

set abcd.inventory; *data being used in data step;

run; 

Contributor
Posts: 29

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

I ran the code:

 

Libname abcd '/folders/myfolders';
Data inventory;
set abcd.inventory;
run;

 

It shows an error message saying "Error: the table work.inventory can not be opened because it does not contain any columns"


Screen Shot 2016-10-13 at 10.39.17 PM.png
Super User
Posts: 19,100

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

Yeah, your initial attempts may have wrecked your original dataset because you were trying to create that dataset (abcd.invemtory)

 

Try replacing the dataset and running the code again. 

Contributor
Posts: 29

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

I tried it with a different data set which I just downloaded "survey.sas7bdat" and saved it in myFolder. The dataset is fine because I can open it by clicking in SAS UE.

 

Still getting Error: ERROR: File DEF.SURVEY.DATA does not exist.


Libname def '/folders/myfolders';
Data survey;
set def.survey;
run;

 

I have even tried using a different path like /folders/myfolders/myData . But no use. Don't know if I am doing something terribly dumb !

 


Screen Shot 2016-10-14 at 11.52.47 AM.png
Super User
Posts: 11,121

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition


shihabur wrote:

 

Libname abcd '/folders/myfolders';
Data inventory;
set abcd.inventory;
run;

 

It shows an error message saying "Error: the table work.inventory can not be opened because it does not contain any columns"


Note that the log behind the Studio message explains to an extent what happened. You have a basically empty set.

As an example look at this code:

Data work.junk;

run;

Does not reference any external data, does not have any code but will generate the message:

NOTE: The data set WORK.JUNK has 1 observations and 0 variables.

 

Apparently you either had an empty set to begin with or the file has been corrupted. Time to find a backup.

 

Also, note that in your first post  there is a message that your ABCD library also refers to DATALIB. While there are some reasons for having multiple libraries point to the same location you really shouldn't be attempting any of them at this stage of learning. Use the existing DATALIB or create a subfolder such as /folders/myfolders/project and reference that for your data related to a project. One of the purposes of a library is to organize things that belong together. So you may have all of the datasets related to your inventory project in one library and party planning in a different library.

 

Contributor
Posts: 29

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

Hi, Thanks for detailed response. I understand that my situation is a similar to where there would be an empty/corrupt file. I just downloaded a different file "survey.sas7bdat" and tried again but only to get same result. I opened the file by clicking and it seems fine as you can see in the attached image.

 

Secondly, I think I have made this mistake of creating too many libraries, probably i should have sticked to only one instead of creating a new one everytime I am running the code. But could that be reason for my problem ?


Screen Shot 2016-10-14 at 11.54.56 AM.png
Super User
Posts: 11,121

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

What code did you run and what do you mean by "same result"? if you ran a data step agains the survey data set DON'T.

Contributor
Posts: 29

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

I ran this code:

 

Libname def '/folders/myFolders';
Data survey;
set def.survey;
run;

 

And got this error:

 

ERROR: File DEF.SURVEY.DATA does not exist.

 

 

What do I do now ?

Super User
Posts: 19,100

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

Assign your library.

 

library test '/folders/myfolders/';

 

proc datasets lib=test;

run;quit;

 

Post the output from the code above please.

 

Is this a new install of SAS UE?

 

Can you show the set up of myfolders in your folder as well?

 

 

Contributor
Posts: 29

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

I installed UE 2 months back. I am attaching the image of how the shared folder looks like now. Turns out as of this moment the correct file path is "/folders/myshortcuts/myFolders"


Screen Shot 2016-10-14 at 1.47.06 PM.png
Super User
Posts: 19,100

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

This is because you used myFolders vs myfolders. SAS UE is on unix and is case sensitive. If you create the folder (myfolders) as noted in the instructions you're original code would have worked. 

 

In general, SAS UE examples tend to rely on myfolders so I would consider creating that folder and adding it correctly. 

 

 

Contributor
Posts: 29

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

I ran the piece of code you asked to run and this is the log.


Screen Shot 2016-10-14 at 1.50.47 PM.png
Contributor
Posts: 29

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

Now I understand. That's why I am seeing this "A shared folder named "myfolders" was not found on the virtual machine" on SAS University Edition Information Center. How I do it now ? I mean how do I change the file path to /folders/myfolders/ ?
Super User
Posts: 19,100

Re: How do I import ".sas7bdat" file by creating a library in SAS University Edition

I woud rename your folder to myfolders - all lower case. 

Then readd it as a shared folder and restart your virtual machine. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 21 replies
  • 2996 views
  • 2 likes
  • 5 in conversation