Solved

How to read a dataset of files in SAS

Posted on 2011-02-14
5
1,385 Views
Last Modified: 2013-11-16
Is there a way for SAS 9.1.3 to read through a folder of Excel files (regardless of Excel version whether Excel 5, Excel 2000, Excel 97, Excel 2003 etc.) to extract information only from a specific tab and save it in a SAS dataset?
0
Comment
Question by:mikecharters
  • 3
5 Comments
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 250 total points
ID: 34894244
first step is to list the contents of the directory into a text file, then read that text file into a sas dataset
you may refer to http://www2.sas.com/proceedings/sugi23/Coders/p82.pdf for some sample

after that, read the contents of the dataset (which will have a lot of things, but most importantly, the filename) into macro variables. you can do this using a data _null_ step and call symput command.

with that, all you are left with is a do loop which loops from 1 to the number of rows in that dataset, and within that loop, do a PROC IMPORT. This assumes the worksheet name to be extracted stays the same for all the files, or some consistent way of identifying the worksheet to be extracted.
0
 

Assisted Solution

by:zuhairpk
zuhairpk earned 250 total points
ID: 34894285
I believe you can accomplish what you want by going throught the follwoing two articles
for getting list of files in folder:
http://support.sas.com/kb/24/820.html
for processing excel files after specifying the sheet name you want
http://www2.sas.com/proceedings/forum2007/119-2007.pdf
hope it helps
0
 

Author Comment

by:mikecharters
ID: 34923557
0
 

Author Comment

by:mikecharters
ID: 34923583
This comment was meant for previous comment but it saved before I expected.

The code above Read.txt is being used to read the Excel files within a folder however I thought it only worked if the files are saved in Excel 5 format (not sure given message below).  

I want to be able to avoid having to convert the files to Excel 5 first and just simply READ the Excel files are they currently exist, which may be in either Excel 5, 97, 2000 or whatever format (but definitely not later than 2003).

Ultimately I only want to be able to read just ONE tab on each Excel file.  In this tab, the variable names themselves are variables with values next to them.  That's not so relevent it's more just getting the the program to simply accept reading the Excel files in the first place and not crash with message:

ERROR: Database error. Examine fields and/or messages below.
Password protected files/cells are not supported.
ERROR: Database table must be entered first

Is there an Unprotect statement that I can add?

Thank you!




0
 

Author Comment

by:mikecharters
ID: 34923689
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How does Google get such fast response times? 5 153
one-way data "masking" MD5 sql 26 146
Error when loading the database 16 57
DBF to ... Converter 5 43
APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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…

895 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

18 Experts available now in Live!

Get 1:1 Help Now