Solved

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

Posted on 2013-06-10
1
431 Views
Last Modified: 2013-06-11
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
Comment
Question by:morinia
1 Comment
 
LVL 8

Accepted Solution

by:
ShannonEE earned 500 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now