SASPairs:
Genetic modeling in SAS

Camille Pissarro, The Shephardess (Girl with Stick)

 

How do I import a MS Excel spreadsheet into SAS?

 

Background:

SAS can import data from an Microsoft (MS) Excel spreadsheet and create a SAS data set from it. Note that in an Excel Workbook, only one of the spreadsheets can be imported at a time. Hence, make a note of the name of the spreadsheet (Sheet) that you want to import from your Workbook.

 

 

Instructions:

 

  1. Decide whether or not you want to save the resulting SAS data set as a permanent SAS data set (i.e., the SAS data set will remain on your computer after you finish the SAS session). If you want to save it as a permanent SAS data set, then assign a Libname to the folder in which you want to save the data set (how do I assign a Libname statement?).
  2. After starting an interactive SAS session, click on the Editor window to make it the active window.
  3. From the File menu, select Import Data ... .
  4. A series of windows will appear. Select the version of Excel, browse to the Excel workbook, and then import the approproate sheet. (NOTE: the SAS window calls the Excel spreadsheet a "table.")
  5. After specifying the sheet, a window will appear asking you where to save the SAS data set. Select the appropriate folder using its SAS "nickname" (i.e., Libname). If you do not want to save it as a permanent SAS data set, then select the Libname WORK. Otherwise, select another Libname. (See illustration below).
  6. Enter a name for the SAS data set.
  7. Click the Finish button.
  8. Check the SAS Log to make certain the spreadsheet was imported correctly.
  9. You may also want to examine the SAS data set (how do I do this?).