I have imported an xlsx file in which columns have numerical names, e.g., 11003, 21003, 21103, and so on (more than 200 variables). The file imported correctly and I see the var names as 11003, 21003, 21103 in the output window and in the proc contents output. However, when I refer to my variables as 11003, 21003, 21103, etc., the SAS Studio does not recognize the variable names and produces an error message. I cannot run even a simple SAS program such as data a; set b; if 21103 eq 0; run; Variables with nonnumerical (character) names are recognized correctly, but if I try to print a mix of variables with nonnumerical and numerical names I get an error:
Try something like this:
options validvarname=any validmemname=extend;
proc print data=coops.full2015;
var ОКПО ОКВЭД '11103'n;
run;
Note the letter n used with the numeric column name.
SAS® 9.4 and SAS® Viya® 3.4 Programming Documentation / SAS Language Reference: Concepts
Rules for SAS Variable Names
Vince DelGobbo
SAS R&D
Try something like this:
options validvarname=any validmemname=extend;
proc print data=coops.full2015;
var ОКПО ОКВЭД '11103'n;
run;
Note the letter n used with the numeric column name.
SAS® 9.4 and SAS® Viya® 3.4 Programming Documentation / SAS Language Reference: Concepts
Rules for SAS Variable Names
Vince DelGobbo
SAS R&D
This works. Many, many thanks.
What is the precise function of the suffix "n"?
Is this topic (var name options, numerical var names in SAS Studio) covered anywhere in the instructions manual or the online help?
Best,
Zlerman
The letter "n" is used to distinguish between a quoted string and a name literal value.
The link that I posted earlier explains this. This link is for the "SAS Name LIterals" section in the same Web page:
Vince DelGobbo
SAS R&D
Thanks much. All is much clearer now, including the terminology ("name literals") and the system options that you have suggested.
Best.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.