- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello everybody;
I have existing dataset sampledata87_02 which has space in variables name like below;
Trade Date
Now I am trying to using this dataset and wants to rename all above variables... . How can I do that?
I am using this logic but its not working.
data sampledata87_02;
set sampledata87_02;
rename
'Trade Date'n=Trade_Date;
run;
The log is:
168 data sampledata87_02;
169 set sampledata87_02;
170 rename
171 'Trade Date'n=Trade_Date;
-------------
24
ERROR 24-322: Variable name is not valid.
172 run;
WARNING: The variable Trade Date in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SAMPLEDATA87_02 may be incomplete. When this step was stopped there
were 0 observations and 18 variables.
WARNING: Data set WORK.SAMPLEDATA87_02 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
Thanks.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Make sure you're seeing the variable name, not label.
The label likely has spaces but the variable name may be automatically converted to the underscore. Run a PROC CONTENTS to see the labels vs data set name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Set:
Options VALIDVARNAME=ANY;
That's one of my subtopics in this blog post about downloading/converting files from the web.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Make sure you're seeing the variable name, not label.
The label likely has spaces but the variable name may be automatically converted to the underscore. Run a PROC CONTENTS to see the labels vs data set name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Wow.. thanks so much for this! I was stuck on this for a while wondering why I kept getting the same error and turns out, my problem wasn't really a problem to begin with because SAS already put the underscores for me.