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


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.
moriniaAdvanced Analytics AnalystAsked:
Who is Participating?
Aloysius LowConnect With a Mentor Commented:
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...
You are looking for the "indirect" function.

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


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.
moriniaAdvanced Analytics AnalystAuthor Commented:
I would like to reference the column in SAS.
Gerald ConnollyConnect With a Mentor Commented:
Look at the column function
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.