BookmarkSubscribeRSS Feed
BoboTheFool
Calcite | Level 5

I need some help and I know this is a super basic question, but i am stumped.  I can create a library in SAS, and then import a dataset into the library from the dropdown menu.  However, when I try to do a libname statement, I get an error.

 

here is example code:

 

libname PROJECT 'P:\Users\amrowland\Desktop\My Documents\organics.csv';

 

304 libname PROJECT 'P:\Users\amrowland\Desktop\My Documents\organics.csv';

NOTE: Library PROJECT does not exist.

 

And under active libraries it has the regular SAS libraries included as well as the project library i created, so I can see the library sitting there.

 

Can anyone help me out, please?

 

Adam

 

 

6 REPLIES 6
Patrick
Opal | Level 21

In general a LIBNAME statement needs to point to a "container" (like a folder) which contains tables. 

 

You've got a .csv file and for this you need to define a FILENAME and then a SAS data step or Proc Import which reads this textual file and stores the result in a table.

BoboTheFool
Calcite | Level 5

So here is what I did -

 

filename project 'P:\Users\amrowland\My Documents\organics.csv';

proc import file=project out=P1 dbms=csv;

run;

 

So it sends the CSV file P1 to the work file, under Work.P1.

libname is still not working at all for me.  I don't know why it is so difficult, as it seems fairly easy.

Cynthia_sas
SAS Super FREQ

The LIBNAME statement should only be used to point to permanent SAS datasets. Your CSV file is NOT a permanent SAS dataset.

Try this...assuming that your My Documents folder exists, as you show your FILENAME statement, then you can also define a LIBNAME there:

libname perm 'P:\Users\amrowland\My Documents';

** Make permanent SAS dataset on P drive folder;
data perm.newclass;
set sashelp.class;
run;

** run reports against permanent data;
proc contents data=perm.newclass;
run;

proc print data=perm.newclass;
run;

Then, once the above works for you, you can change your OUT= in the PROC IMPORT to be OUT=perm.p1 and then your CSV file will be transformed into SAS dataset format. Then, the above LIBNAME statement will point to that location for you.

cynthia

BoboTheFool
Calcite | Level 5

It gives me the error that I don't have the permission to do that.  Can I not create a library to send my dataset to in order to work on it?  Does it need to be a permanent library that I create?  This is super confusing - I am just trying to create a library in which to store my CSV file to do some data mining operations on it, and later down the road am supposed to create another library to store some histograms.  I thought it was not going to be difficult, as I am pretty new to SAS, but it seems downright difficult.

 

libname project 'P:\Users\amrowland\My Documents';

 

ERROR: User does not have appropriate authorization level for library PROJECT.

ERROR: Error in the LIBNAME statement

 

I used perm first and got the same error message.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Are you using SAS University Edition, or what type of SAS are you using?  @Cynthia_sas's code should work fine (assuming there is a folder called: P:\Users\amrowland\My Documents - which you will change to your folder), however that sasumes you are using the full SAS, if you are using UE or one of the other packages then this will be different.

Cynthia_sas
SAS Super FREQ
The fact that the FILENAME statement works using the P drive location indicates that there is READ access to the P: drive location. But not being able to have write permission to that location is not something that SAS can fix.

If you do NOT have WRITE permission to the P drive location, then the LIBNAME statement will NOT work for you to make a dataset there. I recommend that you speak with someone who is the administrator on your system to help you find a folder that you can WRITE to.

For example, if you open Notepad on your computer (Start --> All Programs --> Accessories --> Notepad) and just type a few lines of anything into the file and do a File -- Save As--> can you save a TXT file to that location? Or, alternately, can you make a folder on your C: drive to which you have write access?

If, and only if, you are using SAS University Edition you would need to use a shared folders location and then your LIBNAME statement would be something like this:
libname project '/folders/myfolders/somedir';

But IF you were running the SAS University Edition, you should NOT have been able to read from your P: drive, which is why I suspected that you have a local install of either SAS or Enterprise Guide as an interface to SAS and you have READ access to certain directories, but not WRITE access.

You have to figure out your system and where you can WRITE. Just trying the the LIBNAME statement over and over again won't work without WRITE access. And only someone who understands your system permissions can help you figure out a folder/directory where you have WRITE access.

When you find a folder that you can save to using Notepad, that is a folder that you have WRITE access to.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 9663 views
  • 0 likes
  • 4 in conversation