Accessing your own data sets – not applicable to SAS OnDemand for Academics
In this section, you will learn how to access external data sets in SAS.
⚠️ Important
This topic is applicable for those who are NOT using SAS OnDemand for Academics.
If you are using SAS OnDemand for Academics, please skip this topic and proceed to the next topic.
You can access an external SAS data set by creating a new library.
Let's look at an example.
First, download the CAR data set and save it on your local computer.
In this example, the file has been saved in a folder in the C drive. The exact location path is below:
C:\Users\kisum\Documents\sas_practice
You can save your file anywhere on your PC, as long as the location can be accessed by SAS.
Now, go to your SAS software and run a LIBNAME statement.
LIBNAME Proj1 "C:\Users\kisum\Documents\sas_practice";
The LIBNAME statement is used to create a library that is connected to an external location.
It consists of three parts:
1. LIBNAME
This tells SAS to create a new library.
2. Library Name
The second part of the LIBNAME statement is the library name. In this example, it is PROJ1.
3. Directory Path
Lastly, you will have to specify the path that is connected to the library.
In this example, the library is connected to "C:\Users\kisum\Documents\sas_practice".
Now, run the LIBNAME statement with the path where your CAR data set is located:
LIBNAME Proj1 "Your-directory-path";
You should see a new library created.
It is called PROJ1, and it has the CAR data set in it.
Double click it. You should see the data inside the data set:
Save your progress by creating a free SASCrunch account now.
Exercise
Download the INCOME data set and save it on your local computer.
Create a library that allows you to store and read the INCOME data set.
How many observations are there in the INCOME data set?
HINT:
Write a LIBNAME statement that connects to the external folder where the INCOME data set is located.
SOLUTION:
Libname Proj2 'your-directory-path';
There are 999 observations in the data set.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |