SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mona4u
Lapis Lazuli | Level 10

I got this error when I'm importing a text data file to SAS. 

I know how to solve it by specifying the option 

options validvarname=any;

but I want to know why these variables' names don't fit with SAS variables rules  

 

ERROR: The name RELIF   is not a valid SAS name

ERROR: The name LVEF   is not a valid SAS name.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@mona4u wrote:

I got this error when I'm importing a text data file to SAS. 

I know how to solve it by specifying the option 

options validvarname=any;

but I want to know why these variables' names don't fit with SAS variables rules  

 

ERROR: The name RELIF   is not a valid SAS name

ERROR: The name LVEF   is not a valid SAS name.


When there does not appear to be a character but the error message seems to display an extra character then one possible culprit is a null character, ASCII value 255. Please see:

15   data junk;
16     x =123;
ERROR: The name x  is not a valid SAS name.
17      y=345;
ERROR: The name  y is not a valid SAS name.
18   run;

Notice in the second error there is an extra 'space' before the y and compared with the first error no space after y but is after x.

 

I typed the variable names, in Windows, alt-255 (hold the alt key and enter 255 using the numeric key pad) to add one character before or after y and x.

 

I think you might get a similar behavior if copying code from a non-text file format under some conditions.

We would have to see your code to have a shot at telling if this is the case. If you post code paste it into the code box opened on the forum with the {I} as it is possible that the main message window reformats such characters.

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Can we please see the relevant parts of the SASLOG so we can see what code was submitted and what the error messages were?

--
Paige Miller
mona4u
Lapis Lazuli | Level 10

just edited it

PaigeMiller
Diamond | Level 26

So from now on, in every post you make, we want to see code and SASLOGs posted in the {i} or running man window. No exceptions. Every single time you should do this. Otherwise, we are going to scream.

 

Something like this:

 

19 LVEF   $6
20 LVEFM $50
ERROR: The name LVEF   is not a valid SAS name.

It's not clear to me how this happened, but it appears there are special characters in the variable name that show as spaces. Note the extra spaces after LVEF (but not after LVEFM). Also see the extra spaces after LVEF in the ERROR message. 

 

You might want to try retyping the LVEF and RELIF lines making sure there are no special characters in the line.

 

--
Paige Miller
ballardw
Super User

@mona4u wrote:

I got this error when I'm importing a text data file to SAS. 

I know how to solve it by specifying the option 

options validvarname=any;

but I want to know why these variables' names don't fit with SAS variables rules  

 

ERROR: The name RELIF   is not a valid SAS name

ERROR: The name LVEF   is not a valid SAS name.


When there does not appear to be a character but the error message seems to display an extra character then one possible culprit is a null character, ASCII value 255. Please see:

15   data junk;
16     x =123;
ERROR: The name x  is not a valid SAS name.
17      y=345;
ERROR: The name  y is not a valid SAS name.
18   run;

Notice in the second error there is an extra 'space' before the y and compared with the first error no space after y but is after x.

 

I typed the variable names, in Windows, alt-255 (hold the alt key and enter 255 using the numeric key pad) to add one character before or after y and x.

 

I think you might get a similar behavior if copying code from a non-text file format under some conditions.

We would have to see your code to have a shot at telling if this is the case. If you post code paste it into the code box opened on the forum with the {I} as it is possible that the main message window reformats such characters.

mona4u
Lapis Lazuli | Level 10

It was minor things when I delete the variables and wrote them again it works. 

 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 31634 views
  • 3 likes
  • 3 in conversation