BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
I am new to SAS Enterprise Guide. When I used SAS 8.2, if the variable name has space in between, SAS will automatically add "_". But it seems that EG will leave the space in the variable name. So is there any systemic way to deal with it? For example, I have 100 variables in my raw data. After I import it to SAS, is it possible to add "_" for the space for the variable name automatically? Thanks!
1 ACCEPTED SOLUTION

Accepted Solutions
CaseySmith
SAS Employee

Also, in v6.1, Enterprise Guide added a Naming options section in Tools->Data->Data General that allows you to control the default valid variable and member naming rules (still defaults to validvarname=any and validmemname=extend).  You can change it to V7 if desired to go back to the more restrictive naming rules.

deleteme.png


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

View solution in original post

3 REPLIES 3
Olivier
Pyrite | Level 9
It is related to the VALIDVARNAME=ANY system option used by EG. This will allow any character to be part of a SAS variable name. Can it be totally turned out for the whole SAS EG session ? I don't see how, but this would be the quickest answer to your problem.
Otherwise, you can create a RENAME statement using macros to replace blanks by underscores. Something like that :
[pre]
OPTION VALIDVARNAME = ANY ;
DATA work.test ;
INPUT "my spaced name 1"n "my spaced name 2"n myRegular_SAS_name ;
CARDS ;
1 1 3
1 2 3
;
RUN ;
PROC PRINT DATA = work.test ;
RUN ;
PROC CONTENTS DATA = work.test OUT = work.dictionary NOPRINT ;
RUN ;
PROC SQL NOPRINT ;
SELECT CATS(NLITERAL(name),"=",TRANSLATE(STRIP(name),"_"," ")) INTO : renameList SEPARATED BY " "
FROM work.dictionary
WHERE STRIP(name) CONTAINS " "
;
QUIT ;
PROC DATASETS LIB = work NOLIST ;
MODIFY test ;
RENAME &renameList ;
RUN ; QUIT ;
PROC PRINT DATA = work.test ;
RUN ;
[/pre]
Regards.
Olivier
CaseySmith
SAS Employee

Also, in v6.1, Enterprise Guide added a Naming options section in Tools->Data->Data General that allows you to control the default valid variable and member naming rules (still defaults to validvarname=any and validmemname=extend).  You can change it to V7 if desired to go back to the more restrictive naming rules.

deleteme.png


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 39333 views
  • 2 likes
  • 4 in conversation