Solved

How to read a dataset of files in SAS

Posted on 2011-02-14
5
1,412 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 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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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…

627 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