BookmarkSubscribeRSS Feed
u41125093
Calcite | Level 5

Hey, i'm having trouble referring to variables in excel


PROC UNIVARIATE DATA=SGH;
Var Number_of_pulls_vacuum;
Run;

 

The error statement is:

100 PROC UNIVARIATE DATA=SGH;
101 Var Number_of_pulls_vacuum;
ERROR: Variable NUMBER_OF_PULLS_VACUUM not found.
102 Run;

 

The title of the variable in excel and SAS is Number of pulls vacuum

What am i doing wrong?

2 REPLIES 2
Kurt_Bremser
Super User

@u41125093 wrote:

 

What am i doing wrong?


<snark> You're using Excel </snark>

 

Frankly, what happens is that you have strings in your Excel header line that do not meet the conditions for valid SAS names.

Valid SAS names have a maximum length of 32, contain only letters, digits or underlines, and do not start with a digit.

Since SAS 8 or so, non-standard names can be used with a so-called name literal: "some nonstandard name"n

This only works if

options validvarname=any;

is set.

 

So you have several avenues:

  • change the header lines in Excel to contain valid SAS names (preferred), and rerun the import
  • if validvarname=any is set, the dataset was probably imported with the names as they are, so try "Number of pulls vacuum"n
  • if validvarname=v7 is set, inspect your dataset how the name was imported
ballardw
Super User

What does the output of

 

Proc contents data=sgh;

run;

 

look like?

 

Or show the code you are using to connect to Excel.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Update

SAS Enterprise Guide vs. SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 698 views
  • 0 likes
  • 3 in conversation