BookmarkSubscribeRSS Feed
Anuj_Gupta
Calcite | Level 5
Lets assume I have an excel file which has column name starting with a number(ex 2_Addressline). Is it possible to import the file into SAS and use the variable name as it is? if yes how does it work?

Is there any others s/w which creates the column name starting with a numneral and can be used with SAS datastep?
6 REPLIES 6
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
SAS variables must start with an alpha-character.

You may find reference information at the SAS support website http://support.sas.com/ using the Google advanced search argument below:

dbms import numeric column variable name site:sas.com

Scott Barry
SBBWorks, Inc.

SAS Language Concepts: SAS Variable Attributes
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001103996.htm
ChrisNZ
Tourmaline | Level 20
Alternatively, you can set option validvarname to accept any name form, and use the n extension to tell sas the string is a name.

This is valid:
[pre]
option validvarname=any;
data t;
'2@#$%,./;'n = 'a';
run;
[/pre]

Make sure you have a good reason to do this though.
DanielSantos
Barite | Level 11
Don't know if it helps, but...

Although SAS variables cannot start with a digit, their labels can.

As some reporting tools use the label instead of the variable name (SAS/VIEW, SAS E/G, etc..) and if this suffices, just use the LABEL statement to associate any text you want to the desired variable.

Check the online documentation for the LABEL statement here:
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000201974.htm

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
Anuj_Gupta
Calcite | Level 5
thanks much..
this helps
Anuj_Gupta
Calcite | Level 5
Thanks a lot, this is the best solution I could have got. Is there any way to assign the values of these columns in some other columns or to do any calculations etc.. Message was edited by: Anuj Gupta
Anuj_Gupta
Calcite | Level 5
Hey I found the solution. The columns names starting with numeric are assumed as SAS name literals. To be able to use these variables in datastep we can use following
'variable'n

sas-innovate-wordmark-gradient-background 3.pngSAS Innovate

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 4040 views
  • 0 likes
  • 4 in conversation