• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 508
  • Last Modified:

Best way to read an Excel spreadsheet into SAS to use for analysis

I have an Excel spreadsheet with 0's and 1's as answers to questions.   The spreadsheet is in colum format i.e.:

01a,  01b, 01c, 01d, 01e  respectively for possible answers to question1.

Wht is the most efficient way to read this data in for analysis
0
morinia
Asked:
morinia
1 Solution
 
ShannonEECommented:
Hi there morinia,

If you have access to SAS Enterprise Guide then,

First go into excel and make sure that each column has a name in row 1, that is for your case insert a row above row 01 and then put in names that satisfy SAS criteria for variable names.  While it is possible to have names with blanks and special characters, my suggestion is to choose the alphanumeric names that are going to mean the most to you rather than letting SAS give you its version.
Next make sure that there is no stray information after the last data column and after the last data row.
Give the spreadsheet a useful sheet name and delete all other sheets (even if they don't have any data.

Save the excel file - this will become step 1 in your project.

Next go into Enterprise guide and just import the file - this is straight forward, just make sure that you put the file into a permanent library.  (File -> import data ...).

-------

If you have access to SAS AMO (add in to ms office) then,

open excel
select all the data you want to import,
and select SAS from the menu bar (SAS gets added when you set up the AMO).
The data will be transmitted to SAS for processing.

-------

If you don't have access to Enterprise guide or AMO then, -

Go into excel,
delete all extraneous data  
       delete rows above the start of data (if any)
       delete rows below the end of data
       delete columns to the left and to the right of data

File -> save as
       Under "save as type" select
               Formatted text (space delimited) (*.prn)
       Add a file name  (in this example c:\data\yourSavedFile.prn)
click Save

then in SAS

filename  excel "c:\data\yourSavedFile.prn";
data <libraryName>.spreadsheetData;

     infile excel;
     input name1 name2 name3 ....   nameN;

run;

Open in new window


where you specify a library if you want the data to be permanent.

If there is a large number of variables then you may need options for the record length on the infile statement.

There are other methods, the method above is reasonably simple and should work almost everywhere.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now