Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to read a dataset of files in SAS

Posted on 2011-02-14
5
Medium Priority
?
1,420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 1000 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 1000 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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 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