2

When I load in an excel sheet through PROC IMPORT, locally installed SAS automatically replaces the variable names with spaces to an underscore (_). Such as Patient ID will become Patient_ID and Health Records will become Health_Records.

However, when I load the same file in SAS Studio, that renaming convention isn't applied. So Patient ID and Health Records are kept as is...without the underscore in place.

Thus, how would I call these variables in SAS Studio? A syntax error pops when I try to call IF Patient ID THEN this. Would I have to physically add the underscore to my original dataset or is there an easier way?

Joe
  • 62,789
  • 6
  • 49
  • 67
Ehwic
  • 21
  • 1
  • 3

2 Answers2

4

The difference is caused by the setting of VALIDVARNAME option.

To refer to variable names with spaces you need to use a name-literal for example.

"Patient ID"n

Quoted string followed by the letter N.

data _null_
  • 8,534
  • 12
  • 14
2

As @data_null_ notes, VALIDVARNAME=ANY is what is causing this.

If you want SAS Studio to behave like your desktop SAS, simply add

options validvarname=v7;

to the top of your program (or to some program that will run before your imports, like an autoexec). Then your underscores will return.

Joe
  • 62,789
  • 6
  • 49
  • 67