• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

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

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
morinia
Asked:
morinia
2 Solutions
 
cklukaCommented:
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
 
moriniaAdvanced Analytics AnalystAuthor Commented:
ckluka,
I would like to reference the column in SAS.
0
 
Aloysius LowCommented:
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
 
Gerald ConnollyCommented:
Look at the column function
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now