<?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 Re: How do I rename variable with space starting with ON in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-rename-variable-with-space-starting-with-ON/m-p/796606#M32998</link>
    <description>&lt;P&gt;I do not recommend doing this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, use an underscore instead of a space and then add a descriptive label.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.import2;
 set work.import (rename=(on_methadone=methadone));
label on_methadone = 'On Methadone';
run;

title 'Original Data Set';
proc print data=import (obs=10) noobs label;
var methadone;
run;

title 'New Data Set';
proc print data=import2(obs=10) noobs label;
var on_methadone;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415643"&gt;@manthan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a column in my data set called On Methadone . It has Yes or No as answer choices under the column. I wanted to make a new variable called Methadone with Yes = 1 and No = 2 .. I tried using iF then statement to do this but it didn't work.. and it seems its because there is a space between On and Methadone.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I tried to remove the space by renaming the column by the following command:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=""&gt;data work.import;&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;set work.import (rename=(on methadone=methadone));&lt;/DIV&gt;
&lt;DIV class=""&gt;run;&lt;/DIV&gt;
&lt;DIV class=""&gt;____________but I got the following error::&lt;/DIV&gt;
&lt;DIV class=""&gt;79&lt;/DIV&gt;
&lt;DIV class=""&gt;ERROR 79-322: Expecting a =.&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;Can anyone help me here ? I think the On thing is making it confusing.. not sure though&lt;/DIV&gt;
&lt;PRE class=""&gt;&amp;nbsp;&lt;/PRE&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, 16 Feb 2022 16:08:07 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-02-16T16:08:07Z</dc:date>
    <item>
      <title>How do I rename variable with space starting with ON</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-rename-variable-with-space-starting-with-ON/m-p/796443#M32985</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a column in my data set called On Methadone . It has Yes or No as answer choices under the column. I wanted to make a new variable called Methadone with Yes = 1 and No = 2 .. I tried using iF then statement to do this but it didn't work.. and it seems its because there is a space between On and Methadone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried to remove the space by renaming the column by the following command:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;data work.import;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;set work.import (rename=(on methadone=methadone));&lt;/DIV&gt;&lt;DIV class=""&gt;run;&lt;/DIV&gt;&lt;DIV class=""&gt;____________but I got the following error::&lt;/DIV&gt;&lt;DIV class=""&gt;79&lt;/DIV&gt;&lt;DIV class=""&gt;ERROR 79-322: Expecting a =.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Can anyone help me here ? I think the On thing is making it confusing.. not sure though&lt;/DIV&gt;&lt;PRE class=""&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 03:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-rename-variable-with-space-starting-with-ON/m-p/796443#M32985</guid>
      <dc:creator>manthan</dc:creator>
      <dc:date>2022-02-16T03:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename variable with space starting with ON</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-rename-variable-with-space-starting-with-ON/m-p/796448#M32988</link>
      <description>&lt;P&gt;If the name does not follow normal naming rules then you have to do two things.&lt;/P&gt;
&lt;P&gt;1) Make sure the VALIDVARNAME option is set to ANY .&amp;nbsp; (Or if you are talking about a dataset name that the VALIDMEMNAME option is set to EXTEND).&lt;/P&gt;
&lt;P&gt;2) Use a NAME LITERAL in your code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rename=("on methadone"n=methadone));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Name literals are like DATE literals only you use the letter N instead of the letter D after the quoted string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if the strange name was created by import an external file like an XLSX file or CSV file then you can avoid having SAS create such strange variable names by setting the VALIDVARNAME option to V7.&amp;nbsp; Then PROC IMPORT will use valid variable names for the variables it creates.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 04:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-rename-variable-with-space-starting-with-ON/m-p/796448#M32988</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-16T04:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename variable with space starting with ON</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-rename-variable-with-space-starting-with-ON/m-p/796606#M32998</link>
      <description>&lt;P&gt;I do not recommend doing this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, use an underscore instead of a space and then add a descriptive label.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.import2;
 set work.import (rename=(on_methadone=methadone));
label on_methadone = 'On Methadone';
run;

title 'Original Data Set';
proc print data=import (obs=10) noobs label;
var methadone;
run;

title 'New Data Set';
proc print data=import2(obs=10) noobs label;
var on_methadone;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415643"&gt;@manthan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a column in my data set called On Methadone . It has Yes or No as answer choices under the column. I wanted to make a new variable called Methadone with Yes = 1 and No = 2 .. I tried using iF then statement to do this but it didn't work.. and it seems its because there is a space between On and Methadone.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I tried to remove the space by renaming the column by the following command:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=""&gt;data work.import;&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;set work.import (rename=(on methadone=methadone));&lt;/DIV&gt;
&lt;DIV class=""&gt;run;&lt;/DIV&gt;
&lt;DIV class=""&gt;____________but I got the following error::&lt;/DIV&gt;
&lt;DIV class=""&gt;79&lt;/DIV&gt;
&lt;DIV class=""&gt;ERROR 79-322: Expecting a =.&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;Can anyone help me here ? I think the On thing is making it confusing.. not sure though&lt;/DIV&gt;
&lt;PRE class=""&gt;&amp;nbsp;&lt;/PRE&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, 16 Feb 2022 16:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-rename-variable-with-space-starting-with-ON/m-p/796606#M32998</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-16T16:08:07Z</dc:date>
    </item>
  </channel>
</rss>

