<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Rename Variable with Space in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variable-with-Space/m-p/360849#M274724</link>
    <description>&lt;P&gt;Hello everybody;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have existing dataset sampledata87_02&amp;nbsp;which has space in variables name like below;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Trade Date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I am trying to using this dataset and wants to rename all above variables... . How can I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using this logic but its not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sampledata87_02;
	set sampledata87_02;
	rename 
	'Trade Date'n=Trade_Date;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2017 17:27:11 GMT</pubDate>
    <dc:creator>aminkarimid</dc:creator>
    <dc:date>2017-05-23T17:27:11Z</dc:date>
    <item>
      <title>Rename Variable with Space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variable-with-Space/m-p/360849#M274724</link>
      <description>&lt;P&gt;Hello everybody;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have existing dataset sampledata87_02&amp;nbsp;which has space in variables name like below;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Trade Date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I am trying to using this dataset and wants to rename all above variables... . How can I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using this logic but its not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sampledata87_02;
	set sampledata87_02;
	rename 
	'Trade Date'n=Trade_Date;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 17:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-Variable-with-Space/m-p/360849#M274724</guid>
      <dc:creator>aminkarimid</dc:creator>
      <dc:date>2017-05-23T17:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Variable with Space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variable-with-Space/m-p/360850#M274725</link>
      <description>&lt;P&gt;Set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Options VALIDVARNAME=ANY;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's &lt;A href="http://blogs.sas.com/content/sasdummy/2017/05/07/download-convert-csv-files/" target="_self"&gt;one of my subtopics in this blog post&lt;/A&gt;&amp;nbsp;about downloading/converting files from the web.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 17:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-Variable-with-Space/m-p/360850#M274725</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-05-23T17:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Variable with Space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variable-with-Space/m-p/360891#M274726</link>
      <description>&lt;P&gt;Make sure you're seeing the variable name, not label.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 19:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-Variable-with-Space/m-p/360891#M274726</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-23T19:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Variable with Space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variable-with-Space/m-p/481658#M274727</link>
      <description>&lt;P&gt;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.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 19:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-Variable-with-Space/m-p/481658#M274727</guid>
      <dc:creator>Gabrielle</dc:creator>
      <dc:date>2018-07-26T19:35:04Z</dc:date>
    </item>
  </channel>
</rss>

