10-16-2016 02:31 AM
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?
10-16-2016 02:55 AM
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.
10-16-2016 03:46 AM
So here is what I did -
filename project 'P:\Users\amrowland\My Documents\organics.csv';
proc import file=project out=P1 dbms=csv;
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.
10-16-2016 07:44 AM - edited 10-16-2016 07:44 AM
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;
** run reports against permanent data;
proc contents data=perm.newclass;
proc print data=perm.newclass;
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.
10-17-2016 12:09 AM
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.
10-17-2016 04:47 AM
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.
10-17-2016 09:31 AM