<?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 a variable containing spaces and special characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Renaming-a-variable-containing-spaces-and-special-characters/m-p/698409#M213588</link>
    <description>&lt;P&gt;I am using a dataset that includes a variable called "År för träff". I want to rename the variable to "visityear" but SAS does not recognise the variable name "År för träff". I have tried:&amp;nbsp;&lt;BR /&gt;options validmemname=extend;&lt;BR /&gt;options validvarname=any;&lt;/P&gt;&lt;P&gt;rename "År för träff"n=visityear;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but I get error messages. Does anyone know how to solve this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2020 15:43:25 GMT</pubDate>
    <dc:creator>Leonina_0811</dc:creator>
    <dc:date>2020-11-12T15:43:25Z</dc:date>
    <item>
      <title>Renaming a variable containing spaces and special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-a-variable-containing-spaces-and-special-characters/m-p/698409#M213588</link>
      <description>&lt;P&gt;I am using a dataset that includes a variable called "År för träff". I want to rename the variable to "visityear" but SAS does not recognise the variable name "År för träff". I have tried:&amp;nbsp;&lt;BR /&gt;options validmemname=extend;&lt;BR /&gt;options validvarname=any;&lt;/P&gt;&lt;P&gt;rename "År för träff"n=visityear;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but I get error messages. Does anyone know how to solve this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 15:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-a-variable-containing-spaces-and-special-characters/m-p/698409#M213588</guid>
      <dc:creator>Leonina_0811</dc:creator>
      <dc:date>2020-11-12T15:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a variable containing spaces and special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-a-variable-containing-spaces-and-special-characters/m-p/698412#M213590</link>
      <description>&lt;P&gt;What encoding is your session using.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a test program that works fine for me in a SAS session using UTF-8 encoding and one using WLATIN1 encoding.&amp;nbsp; Note that when I pasted the code into the editor in the WLATIN1 session it automatically changed the encoding of the name in the code.&amp;nbsp; You can tell because Display Manager logs do not support UTF-8 encoding. So the log from the UTF-8 session looks different because it is trying the display the bytes in the UTF-8 string using the single byte encodings of WLATIN1.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;
data test;
  "År för träff"n=2020;
run;

proc datasets nolist lib=work;
modify test;
  rename "År för träff"n=visityear;
run;
quit;

%put %sysfunc(getoption(encoding));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;342   options validvarname=any;
343   data test;
344     "Ã…r fÃ¶r trÃ¤ff"n=2020;
345   run;

NOTE: The data set WORK.TEST has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.03 seconds


346
347   proc datasets nolist lib=work;
348   modify test;
349     rename "Ã…r fÃ¶r trÃ¤ff"n=visityear;
NOTE: Renaming variable 'Ã…r fÃ¶r trÃ¤ff'n to visityear.
350   run;

NOTE: MODIFY was successful for WORK.TEST.DATA.
351   quit;

NOTE: PROCEDURE DATASETS used (Total process time):
      real time           0.05 seconds
      cpu time            0.03 seconds


352   %put %sysfunc(getoption(encoding));
UTF-8
&lt;/PRE&gt;
&lt;PRE&gt;77    options validvarname=any;
78    data test;
79      "År för träff"n=2020;
80    run;

NOTE: The data set WORK.TEST has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.03 seconds


81
82    proc datasets nolist lib=work;
83    modify test;
84      rename "År för träff"n=visityear;
NOTE: Renaming variable 'År för träff'n to visityear.
85    run;

NOTE: MODIFY was successful for WORK.TEST.DATA.
86    quit;

NOTE: PROCEDURE DATASETS used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds


87
88    %put %sysfunc(getoption(encoding));
WLATIN1
&lt;/PRE&gt;
&lt;P&gt;How did the variable get created with that name?&amp;nbsp; Perhaps you can just change the step that is making the dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 16:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-a-variable-containing-spaces-and-special-characters/m-p/698412#M213590</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-12T16:01:37Z</dc:date>
    </item>
  </channel>
</rss>

