<?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 suffix/prefix to all data in a column? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/add-suffix-prefix-to-all-data-in-a-column/m-p/798256#M313820</link>
    <description>&lt;P&gt;Since you already have a variable adding additional characters may mean that the suffix/prefix could make the new value too long to fit in the existing variable. So in a new data set you need to do something to make the length long enough to hold the largest expected value.&lt;/P&gt;
&lt;P&gt;One way using a Length statement:&lt;/P&gt;
&lt;PRE&gt;data have;
/* read with a fixed 3 characters to create that length*/
INPUT ID $3.;
DATALINES;
AZ1
AZ2
AZ3
;
RUN;

data want;
   /*this length statement adds 3 characters to hold the suffix*/
   length id $ 6.;
   set have;
   id = cats(id,'_22');
run;
&lt;/PRE&gt;
&lt;P&gt;The CATS function will remove trailing spaces from values and concatenate values from left to right into a new value.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Feb 2022 21:22:01 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-02-23T21:22:01Z</dc:date>
    <item>
      <title>add suffix/prefix to all data in a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-suffix-prefix-to-all-data-in-a-column/m-p/798247#M313817</link>
      <description>&lt;P&gt;Hey everyone, I want to add a suffix to all data in a column,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
INPUT ID $;
DATALINES;
AZ1
AZ2
AZ3
;
RUN;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm trying to make the data look like this&lt;/P&gt;&lt;PRE&gt;ID&lt;BR /&gt;AZ1_22
AZ2_22
AZ3_22&lt;/PRE&gt;&lt;P&gt;I would appreciate any help, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 20:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-suffix-prefix-to-all-data-in-a-column/m-p/798247#M313817</guid>
      <dc:creator>togglefroggle</dc:creator>
      <dc:date>2022-02-23T20:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: add suffix/prefix to all data in a column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-suffix-prefix-to-all-data-in-a-column/m-p/798256#M313820</link>
      <description>&lt;P&gt;Since you already have a variable adding additional characters may mean that the suffix/prefix could make the new value too long to fit in the existing variable. So in a new data set you need to do something to make the length long enough to hold the largest expected value.&lt;/P&gt;
&lt;P&gt;One way using a Length statement:&lt;/P&gt;
&lt;PRE&gt;data have;
/* read with a fixed 3 characters to create that length*/
INPUT ID $3.;
DATALINES;
AZ1
AZ2
AZ3
;
RUN;

data want;
   /*this length statement adds 3 characters to hold the suffix*/
   length id $ 6.;
   set have;
   id = cats(id,'_22');
run;
&lt;/PRE&gt;
&lt;P&gt;The CATS function will remove trailing spaces from values and concatenate values from left to right into a new value.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 21:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-suffix-prefix-to-all-data-in-a-column/m-p/798256#M313820</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-23T21:22:01Z</dc:date>
    </item>
  </channel>
</rss>

