How to Import Excel Files into SAS (With Example)

Statology

You can use proc import to quickly import data from an Excel file into SAS. This procedure uses the following basic syntax:

/*import data from Excel file called my_data.xlsx*/ proc import out=my_data datafile="/home/u13181/my_data.xlsx" dbms=xlsx replace; getnames=YES; run;

The following example shows how to use this function in practice.

Example: Import Data from Excel File into SAS

Suppose we have the following dataset in Excel:

We can use the following code to import this dataset into SAS and call it new_data:

/*import data from Excel file called my_data.xlsx*/ proc import out=new_data datafile="/home/u13181/my_data.xlsx" dbms=xlsx replace; getnames=YES; run; /*view dataset*/ proc print data=new_data;

The data shown in the SAS output matches the data shown in the Excel file.

Note: We used getnames=YES when importing the file since the first row of the Excel file contained variable names.

Additional Resources

The following tutorials explain how to perform other common tasks in SAS:

Hey there. My name is Zach Bobbitt. I have a Masters of Science degree in Applied Statistics and I’ve worked on machine learning algorithms for professional businesses in both healthcare and retail. I’m passionate about statistics, machine learning, and data visualization and I created Statology to be a resource for both students and teachers alike. My goal with this site is to help you learn statistics through using simple terms, plenty of real-world examples, and helpful illustrations.