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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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