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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 749 views
  • 0 likes
  • 3 in conversation