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 -
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;
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;
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"
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.
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 !
@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.
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 ?
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.
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 ?
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?
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"
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.
I ran the piece of code you asked to run and this is the log.
I woud rename your folder to myfolders - all lower case.
Then readd it as a shared folder and restart your virtual machine.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.