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
Solved

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

Posted on 2013-11-05
4
353 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 17

Assisted Solution

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

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SYbase 4 36
mysql database, schema and table creation 13 57
Exchange 2013 tmp files 3 40
MySQL Query Using Up Memory 6 43
I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
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…
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…

809 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