Solved

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

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

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

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…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
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…

816 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

11 Experts available now in Live!

Get 1:1 Help Now