<?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 Replacing variable values with values with a space in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385438#M92191</link>
    <description>&lt;P&gt;I need to merge two data sets, but one of them has one thing labelled two ways: "Place A" and "Place_A". I want to keep it as "Place A" Because I am plotting this data later on and the _ is not a beautiful thing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I need to merge the data sets based on place, but that is not the issue here, I am trying to replace "Place_A" with "Place A" in one data set so when I merge, they are recognized as the same variable. Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;if PLACE = Place_A then PLACE = 'Place A'n;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error: "Place A is not a valid SAS name".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is in SAS 9.2 Unix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Aug 2017 18:51:38 GMT</pubDate>
    <dc:creator>abak</dc:creator>
    <dc:date>2017-08-03T18:51:38Z</dc:date>
    <item>
      <title>Replacing variable values with values with a space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385438#M92191</link>
      <description>&lt;P&gt;I need to merge two data sets, but one of them has one thing labelled two ways: "Place A" and "Place_A". I want to keep it as "Place A" Because I am plotting this data later on and the _ is not a beautiful thing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I need to merge the data sets based on place, but that is not the issue here, I am trying to replace "Place_A" with "Place A" in one data set so when I merge, they are recognized as the same variable. Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;if PLACE = Place_A then PLACE = 'Place A'n;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error: "Place A is not a valid SAS name".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is in SAS 9.2 Unix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 18:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385438#M92191</guid>
      <dc:creator>abak</dc:creator>
      <dc:date>2017-08-03T18:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing variable values with values with a space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385443#M92194</link>
      <description>&lt;P&gt;Take a look at&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000279245.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000279245.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm#a000998933" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm#a000998933&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 18:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385443#M92194</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-08-03T18:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing variable values with values with a space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385451#M92199</link>
      <description>&lt;P&gt;I assume you have a variable named PLACE in your input and you want to replace '_' with ' ' then&lt;/P&gt;
&lt;P&gt;either do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;place = translate(place,' ','_'); /* arguments: variable name, replacement, to be replaced */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or correct your code using literals to distinguish from variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if place = 'Place_A'  then place = 'Place A';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in this case you can use either single quotes or double quotes.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 19:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385451#M92199</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-08-03T19:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing variable values with values with a space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385454#M92200</link>
      <description>&lt;P&gt;Thank you, I added VALIDVARNAME = ANY in the data statement and it told me that it created a data set with 0 observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test VALIDVARNAME = ANY;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if PLACE = Place_A then PLACE = 'Place A'n;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; VALIDVARNAME = ANY&lt;/P&gt;&lt;P&gt;&amp;nbsp; if PLACE = Place_A then PLACE = 'Place A'n;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 19:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385454#M92200</guid>
      <dc:creator>abak</dc:creator>
      <dc:date>2017-08-03T19:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing variable values with values with a space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385457#M92201</link>
      <description>&lt;P&gt;Just to clarify, I have a variable named PLACE and it has some of its values named Place_A that I want to change to Place A&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 19:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385457#M92201</guid>
      <dc:creator>abak</dc:creator>
      <dc:date>2017-08-03T19:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing variable values with values with a space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385458#M92202</link>
      <description>&lt;P&gt;You are mixing variable name with variable value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is 'Place_A' a variable name ? If YES maybe you want to &amp;nbsp;add&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; LABEL Place_A = 'Place A';&lt;/P&gt;
&lt;P&gt;then define you prefer use lables in the chart/report instead variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise - see my previous post.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 19:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-variable-values-with-values-with-a-space/m-p/385458#M92202</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-08-03T19:23:39Z</dc:date>
    </item>
  </channel>
</rss>

