Solved

Accessing a spreadsheet by column instead of name after importing from Excel

Posted on 2013-11-05
4
325 Views
Last Modified: 2013-11-11
Experts,

I was wondering if there is a way to access a column  in Excel by column (i.e. Column A) in lieu of the column heading in SAS.  This would allow flexibility of bypassing column headings which may be long or descriptive in Excel but not good for a SAS variable name.
0
Comment
Question by:morinia
4 Comments
 
LVL 5

Expert Comment

by:ckluka
ID: 39624381
You are looking for the "indirect" function.

http://office.microsoft.com/en-gb/excel-help/indirect-HP005209139.aspx


You can address a cell (B3) for example two ways:

=indirect(B3,TRUE)
=indirect(R3C2,FALSE)

You can replace "B3" or "R3C2" with a string literal or cell reference so you can use it in a formula or function to iterate through a list or entire column.
0
 

Author Comment

by:morinia
ID: 39624415
ckluka,
I would like to reference the column in SAS.
0
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 200 total points
ID: 39626215
you using proc import code? try naming the columns (i.e. row 1) as numbers and import again - you should see the Excel column as the column name i.e. A - Z, AA - ZZ etc etc

at least that's how it's appearing to me... otherwise, if you don't wish to rename the columns that you have already, set validvarname option to any (i.e. options validvarname = any;)

you can reference the column names by adding a quotation marks and a letter n (i.e. 'field name'n) however, this does not avoid the 32 characters length limitation set...
0
 
LVL 16

Assisted Solution

by:Gerald Connolly
Gerald Connolly earned 100 total points
ID: 39626939
Look at the column function
0

Featured Post

Highfive Gives IT Their Time Back

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

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Creating and Managing Databases with phpMyAdmin in cPanel.
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…

758 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

23 Experts available now in Live!

Get 1:1 Help Now