Sas Studio-Dealing with Variable Names That Have Spaces
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...
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?
2 Answers
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.
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.