<?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: Variable not found and cannot be renamed in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817796#M322802</link>
    <description>&lt;P&gt;Variable names cannot have a dash (hyphen) in the variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can override this with the following option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then you can refer to variables in your code with dash in their name as, for example,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tables 'U-METHADONE'n;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jun 2022 14:14:39 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-06-13T14:14:39Z</dc:date>
    <item>
      <title>Variable not found and cannot be renamed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817794#M322801</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a sas dataset that has some variables that was not presenting frequencies. The variables are named and label like this;&amp;nbsp; U-METHADONE, U-OXY, U-FENTANYL.&lt;/P&gt;&lt;P&gt;How can I resolve this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data = original_data;&lt;BR /&gt;tables U-METHADONE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;*LOG;&lt;/P&gt;&lt;DIV class=""&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class=""&gt;68&lt;/DIV&gt;&lt;DIV class=""&gt;69 proc freq data = original_data;&lt;/DIV&gt;&lt;DIV class=""&gt;70 tables U-METHADONE;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT color="#FF0000"&gt;ERROR: Variable U not found.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;71 run;&lt;/DIV&gt;&lt;P&gt;I have attempted to rename the variables but no luck.&lt;/P&gt;&lt;P&gt;data new_data;&lt;BR /&gt;set&amp;nbsp;original_data (rename=(U-METHADONE=Methadone));&lt;BR /&gt;keep Methadone ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;*LOG;&lt;/P&gt;&lt;DIV class=""&gt;69 data new_data;&lt;/DIV&gt;&lt;DIV class=""&gt;70 set stcp.cleanedpracticum2(rename=(U-METHADONE=Methadone));&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT color="#FF0000"&gt;ERROR: U does not have a numeric suffix.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;71 keep Methadone;&lt;/DIV&gt;&lt;DIV class=""&gt;72 run;&lt;/DIV&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 14:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817794#M322801</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2022-06-13T14:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not found and cannot be renamed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817796#M322802</link>
      <description>&lt;P&gt;Variable names cannot have a dash (hyphen) in the variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can override this with the following option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then you can refer to variables in your code with dash in their name as, for example,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tables 'U-METHADONE'n;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 14:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817796#M322802</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-13T14:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not found and cannot be renamed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817797#M322803</link>
      <description>&lt;P&gt;Hyphens are not allowed in valid variable names.&amp;nbsp; It thinks you are trying to do some type of variable list, but the syntax is not right for that either as for a variable list using a single hyphen you need names with a numeric suffix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have the validvarname option set to ANY (why?) then you need to use a Name Literal to reference a variable name that does not follow normal naming rules.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tables "U-METHADONE"n;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise if you have validvarname=v7 then you are probably trying to use the LABEL of the variable where you should be using the NAME of the variable.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 14:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817797#M322803</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-13T14:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not found and cannot be renamed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817798#M322804</link>
      <description>&lt;P&gt;Show us the output of PROC CONTENTS on this data set for these variables.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 14:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817798#M322804</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-13T14:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not found and cannot be renamed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817808#M322808</link>
      <description>&lt;P&gt;Thank you. The problem is solved. I still sent you a snippet of the proc content if you still need it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CathyVI_0-1655131124784.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72188iEC035B39E04703A8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CathyVI_0-1655131124784.png" alt="CathyVI_0-1655131124784.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 14:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817808#M322808</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2022-06-13T14:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Variable not found and cannot be renamed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817810#M322810</link>
      <description>&lt;P&gt;Thanks! But as long as the problem is solved, the PROC CONTENTS is no longer needed.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2022 14:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-not-found-and-cannot-be-renamed/m-p/817810#M322810</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-13T14:43:09Z</dc:date>
    </item>
  </channel>
</rss>

