1
votes

I'm new to SAS and Enterprise Guide and am having problems getting my head around some basic concepts. Please could someone explain the relationship between libraries, projects, libname and libref? I am following the SAS eLearning course but when I try to link a library with the datafiles stored on my machine I keep getting the message that the library doesn't exist, even though it's right there in the Server List.

Thanks in advance

2

2 Answers

1
votes

I'm taking a college level SAS course atm. From what I have learnt, libref is a name in which you associate the physical location of a group of files to SAS. The libname statement creates a library reference (libref) for a SAS program. In general, the basic syntax of libname is:

libname libref 'path';

For example:

libname sales 'C:\salesdata\journal\june';

In other words, for SAS to be able to read and write data from a dataset, it must know the directory or folders that contains the particular dataset. SAS calls what we humans call directory or folders as "libraries". SAS also assigns nicknames (libref) to these libraries and use the libname statement to assign the nickname to a specific folder.

For example if you want to print an existing SAS dataset located inside the "june" folder, you can do this:

libname sales 'C:\salesdata\journal\june';

proc print data = sales.revenue;
run;

SAS will print the data portion of the "revenue" dataset that is located inside the "june" folder because we have assigned sales to that folder. Hope this helps.

1
votes

Particularly if you're using SAS OnDemand for your training (as I assume you are), it's unlikely you will be able to directly assign a libname to your local datafiles. You'd have to provide more information as to the location/etc. of the datafiles you're trying to access to get a better answer, but in general, if you are running SAS on a server (Enterprise Guide is the GUI you're using to connect, SAS itself is the process that actually does the frequencies/etc. and is likely on a server somewhere, in the cloud or in your company's server farm).

The key concept is that a libname must be accessible on the machine running the SAS server instance. While it is possible you might have set up your network such that the server has mapped your local machine's hard disk to a drive, this is not the case in most instances. If you're on a network and you have access to a network drive that the SAS Server also has access to, you could share information that way; but if you are running SAS in the cloud (such as for training/educational purposes with SAS OnDemand), you probably cannot access any shared drives.

Chris Hemedinger (one of the SAS folk who used to work on EG) wrote a custom task, available at this link to help copy files from local desktop to remote server. This may not be helpful with SAS OnDemand, as I think those don't permit copying files up.