<?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 Renaming in data step not working in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Renaming-in-data-step-not-working/m-p/764059#M30468</link>
    <description>&lt;P&gt;Hello everybody&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have existing dataset covid which has space in variables name like below:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;numero expediente del paciente&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried renaming them assuming SAS would turn spaces into underscores but when I run the program it sends a warning that the variable does not exist in the dataset. I have run PROC CONTENTS and the variables are there, but the variable name appears without underscores. The original data came from an excel file but I changed it into SAS data. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here's the code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;libname COVIDBD '/home/mercedesaguilars0/sasuser.v94/SASMer';&lt;/P&gt;&lt;P&gt;data base;&lt;BR /&gt;set covidbd.covid;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;NOTE: There were 398 observations read from the data set COVIDBD.COVID.&lt;/P&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The data set WORK.BASE has 398 observations and 199 variables.&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data base2;&lt;BR /&gt;set base&lt;BR /&gt;(rename=(numero_expediente_del_paciente=numexp));&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variable numero_expediente_del_paciente is not on file WORK.BASE2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Aug 2021 21:55:24 GMT</pubDate>
    <dc:creator>MerAgSo</dc:creator>
    <dc:date>2021-08-25T21:55:24Z</dc:date>
    <item>
      <title>Renaming in data step not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Renaming-in-data-step-not-working/m-p/764059#M30468</link>
      <description>&lt;P&gt;Hello everybody&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have existing dataset covid which has space in variables name like below:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;numero expediente del paciente&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried renaming them assuming SAS would turn spaces into underscores but when I run the program it sends a warning that the variable does not exist in the dataset. I have run PROC CONTENTS and the variables are there, but the variable name appears without underscores. The original data came from an excel file but I changed it into SAS data. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here's the code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;libname COVIDBD '/home/mercedesaguilars0/sasuser.v94/SASMer';&lt;/P&gt;&lt;P&gt;data base;&lt;BR /&gt;set covidbd.covid;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;NOTE: There were 398 observations read from the data set COVIDBD.COVID.&lt;/P&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The data set WORK.BASE has 398 observations and 199 variables.&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data base2;&lt;BR /&gt;set base&lt;BR /&gt;(rename=(numero_expediente_del_paciente=numexp));&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variable numero_expediente_del_paciente is not on file WORK.BASE2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 21:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Renaming-in-data-step-not-working/m-p/764059#M30468</guid>
      <dc:creator>MerAgSo</dc:creator>
      <dc:date>2021-08-25T21:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming in data step not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Renaming-in-data-step-not-working/m-p/764063#M30469</link>
      <description>&lt;P&gt;You need to use what SAS calls a "name literal".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just as&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;A number, say like 5, is a numeric literal&amp;nbsp; &amp;nbsp;(as in X=5).&lt;/LI&gt;
&lt;LI&gt;A quoted string is a character literal&amp;nbsp; &amp;nbsp;(as in Y='This is a string')&lt;/LI&gt;
&lt;LI&gt;A&amp;nbsp; '.....'d is a date literal&amp;nbsp; &amp;nbsp;(renew_date='25Aug2021'd)&lt;/LI&gt;
&lt;LI&gt;'....'t is a time literal&amp;nbsp; &amp;nbsp;(lunch_time='13:00:00't)&lt;/LI&gt;
&lt;LI&gt;'...'dt is a datetime literal&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are some others too (hexadecimal literals come to mind).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you need to use a&amp;nbsp;name literal, expressed as &lt;EM&gt;&lt;STRONG&gt;'this is a variable name'n&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp; So in your example, you probably should use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set base
(rename=('numero expediente del paciente'n=numexp)); &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS &lt;EM&gt;&lt;STRONG&gt;does NOT&lt;/STRONG&gt;&lt;/EM&gt; replace blanks in a name with underscores.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 22:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Renaming-in-data-step-not-working/m-p/764063#M30469</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-08-25T22:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming in data step not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Renaming-in-data-step-not-working/m-p/764065#M30470</link>
      <description>&lt;P&gt;If your variable names contain spaces then you will probably need to do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data base2;
set base
(rename=('numero expediente del paciente'n = numexp)); 
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Aug 2021 22:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Renaming-in-data-step-not-working/m-p/764065#M30470</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-08-25T22:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming in data step not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Renaming-in-data-step-not-working/m-p/764066#M30471</link>
      <description>&lt;P&gt;Set this option and reimport your data to avoid the issue entirely.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname = v7;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have this option set, when you import data SAS will automatically add the underscores to the variable names as necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/197667"&gt;@MerAgSo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello everybody&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have existing dataset covid which has space in variables name like below:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;numero expediente del paciente&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I tried renaming them assuming SAS would turn spaces into underscores but when I run the program it sends a warning that the variable does not exist in the dataset. I have run PROC CONTENTS and the variables are there, but the variable name appears without underscores. The original data came from an excel file but I changed it into SAS data. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here's the code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;libname COVIDBD '/home/mercedesaguilars0/sasuser.v94/SASMer';&lt;/P&gt;
&lt;P&gt;data base;&lt;BR /&gt;set covidbd.covid;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;NOTE: There were 398 observations read from the data set COVIDBD.COVID.&lt;/P&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;NOTE: The data set WORK.BASE has 398 observations and 199 variables.&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data base2;&lt;BR /&gt;set base&lt;BR /&gt;(rename=(numero_expediente_del_paciente=numexp));&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variable numero_expediente_del_paciente is not on file WORK.BASE2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 22:31:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Renaming-in-data-step-not-working/m-p/764066#M30471</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-08-25T22:31:27Z</dc:date>
    </item>
  </channel>
</rss>

