<?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: Add character string to every value of some variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-character-string-to-every-value-of-some-variable/m-p/766267#M242836</link>
    <description>&lt;P&gt;Or&lt;/P&gt;
&lt;P&gt;newvar = cats(item,'_fruit');&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;newvar = strip(item)||'_fruit';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The || operator may leave some spaces you don't want in the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You likely need to create a new variable as the length of the variable item is already set and adding additional characters may exceed that length, or play some games with a Length statement if you want to use the same variable name.&lt;/P&gt;
&lt;P&gt;This would look like (assumes making the variable length 25 will hold existing text plus the text you intend to add)&lt;/P&gt;
&lt;PRE&gt;data want; 
   length item $ 25;
   set have;
   item= cats(item,'_fruit');
run;&lt;/PRE&gt;
&lt;P&gt;The above would have a possibly unwanted behavior; item becomes the first column in the data set which some people have issues with column order;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Sep 2021 21:05:08 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-09-06T21:05:08Z</dc:date>
    <item>
      <title>Add character string to every value of some variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-character-string-to-every-value-of-some-variable/m-p/766254#M242833</link>
      <description>&lt;P&gt;I'll start searching for the answer, but thought I'd put the question here first:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would one add a character string to every value of some variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i.e., Variable is Item...&lt;/P&gt;
&lt;P&gt;apple&lt;/P&gt;
&lt;P&gt;banana&lt;/P&gt;
&lt;P&gt;grape&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;becomes:&lt;/P&gt;
&lt;P&gt;apple_fruit&lt;/P&gt;
&lt;P&gt;banana_fruit&lt;/P&gt;
&lt;P&gt;grape_fruit&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Solution greatly appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 19:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-character-string-to-every-value-of-some-variable/m-p/766254#M242833</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2021-09-06T19:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Add character string to every value of some variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-character-string-to-every-value-of-some-variable/m-p/766255#M242834</link>
      <description>&lt;P&gt;just put newvar=item||'_fruit' in a data step.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 19:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-character-string-to-every-value-of-some-variable/m-p/766255#M242834</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-09-06T19:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Add character string to every value of some variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-character-string-to-every-value-of-some-variable/m-p/766267#M242836</link>
      <description>&lt;P&gt;Or&lt;/P&gt;
&lt;P&gt;newvar = cats(item,'_fruit');&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;newvar = strip(item)||'_fruit';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The || operator may leave some spaces you don't want in the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You likely need to create a new variable as the length of the variable item is already set and adding additional characters may exceed that length, or play some games with a Length statement if you want to use the same variable name.&lt;/P&gt;
&lt;P&gt;This would look like (assumes making the variable length 25 will hold existing text plus the text you intend to add)&lt;/P&gt;
&lt;PRE&gt;data want; 
   length item $ 25;
   set have;
   item= cats(item,'_fruit');
run;&lt;/PRE&gt;
&lt;P&gt;The above would have a possibly unwanted behavior; item becomes the first column in the data set which some people have issues with column order;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 21:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-character-string-to-every-value-of-some-variable/m-p/766267#M242836</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-06T21:05:08Z</dc:date>
    </item>
  </channel>
</rss>

