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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 38971 views
  • 2 likes
  • 4 in conversation