<?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: combine numeric&amp;amp;string to new var in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461670#M117475</link>
    <description>&lt;P&gt;You haven't told us something, but I don't know what that something is. The following worked for me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Id;
  cards; 
89
180
2003
39123
;

data want;
  set have;
  Unique_A200_2018=catt('A200_2018_',id);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 May 2018 18:56:37 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2018-05-11T18:56:37Z</dc:date>
    <item>
      <title>combine numeric&amp;string to new var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461567#M117434</link>
      <description>&lt;P&gt;I have a data set that need to be updated.&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;Id&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;89&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;180&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2003&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;39123&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to create a new string var "Unique_A200_2018" based on the id# &lt;STRONG&gt;and&lt;/STRONG&gt;&amp;nbsp;A200_2018. So, for id 89, his new Unique_A200_2018 is A200_2018_89.&amp;nbsp; id 39123, the new Unique_A200_2018 is A200_2018_39123 and so on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;New in SAS world, please help. Thanks, Shirley.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 15:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461567#M117434</guid>
      <dc:creator>Bintang18</dc:creator>
      <dc:date>2018-05-11T15:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: combine numeric&amp;string to new var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461570#M117435</link>
      <description>&lt;P&gt;There's a function for that! e.g.:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  Unique_A200_2018=catt('A200_2018_',id);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 15:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461570#M117435</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-05-11T15:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: combine numeric&amp;string to new var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461584#M117438</link>
      <description>&lt;P&gt;This is what I got. I know, I have to fix&amp;nbsp; var property, but how about the invalid argument. Did I miss something?&lt;/P&gt;&lt;P&gt;BTW, id is numeric&lt;/P&gt;&lt;P&gt;Thank you again.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;WARNING: In a call to the CATT function, the buffer allocated for the result&lt;BR /&gt;was not long enough to contain the concatenation of all the arguments.&lt;BR /&gt;The correct result would contain 12 characters, but the actual result&lt;BR /&gt;might either be truncated to 1 character(s) or be completely blank,&lt;BR /&gt;depending on the calling environment. The following note indicates the&lt;BR /&gt;left-most argument that caused truncation.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: Argument 1 to function CATT('A200_2018_',78) at line 40 column 22 is&lt;BR /&gt;invalid.&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 15:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461584#M117438</guid>
      <dc:creator>Bintang18</dc:creator>
      <dc:date>2018-05-11T15:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: combine numeric&amp;string to new var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461670#M117475</link>
      <description>&lt;P&gt;You haven't told us something, but I don't know what that something is. The following worked for me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Id;
  cards; 
89
180
2003
39123
;

data want;
  set have;
  Unique_A200_2018=catt('A200_2018_',id);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 18:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461670#M117475</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-05-11T18:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: combine numeric&amp;string to new var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461729#M117487</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209554"&gt;@Bintang18&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;This is what I got. I know, I have to fix&amp;nbsp; var property, but how about the invalid argument. Did I miss something?&lt;/P&gt;
&lt;P&gt;BTW, id is numeric&lt;/P&gt;
&lt;P&gt;Thank you again.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;WARNING: In a call to the CATT function, the buffer allocated for the result&lt;BR /&gt;was not long enough to contain the concatenation of all the arguments.&lt;BR /&gt;The correct result would contain 12 characters, but the actual result&lt;BR /&gt;might either be truncated to 1 character(s) or be completely blank,&lt;BR /&gt;depending on the calling environment. The following note indicates the&lt;BR /&gt;left-most argument that caused truncation.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NOTE: Argument 1 to function CATT('A200_2018_',78) at line 40 column 22 is&lt;BR /&gt;invalid.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you copy and paste code from the forum? If the code is not in a code box, such as this opened with the {I}&lt;/P&gt;
&lt;PRE&gt;something = CATT('A200_2018_',var);&lt;/PRE&gt;
&lt;P&gt;or the box from the "running man" icon:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;something = CATT('A200_2018_',var);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you might have accidentally picked up some invisible html or similar code. If you did copy/paste then try deleting the line of code and retyping.&lt;/P&gt;
&lt;P&gt;I ran into one example on this site where a block of datalines had about one instance of "hidden" characters per line. Went through a lot of run the data step, read the errors, retype a data value. Repeat. The editor did not give any indication what those values might have been, there were "invisible" as far as the editor was concerned.&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 23:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461729#M117487</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-11T23:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: combine numeric&amp;string to new var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461751#M117491</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209554"&gt;@Bintang18&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;This is what I got. I know, I have to fix&amp;nbsp; var property, but how about the invalid argument. Did I miss something?&lt;/P&gt;
&lt;P&gt;BTW, id is numeric&lt;/P&gt;
&lt;P&gt;Thank you again.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;WARNING: In a call to the CATT function, the buffer allocated for the result&lt;BR /&gt;was not long enough to contain the concatenation of all the arguments.&lt;BR /&gt;The correct result would contain 12 characters, but the actual result&lt;BR /&gt;might either be truncated to 1 character(s) or be completely blank,&lt;BR /&gt;depending on the calling environment. The following note indicates the&lt;BR /&gt;left-most argument that caused truncation.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NOTE: Argument 1 to function CATT('A200_2018_',78) at line 40 column 22 is&lt;BR /&gt;invalid.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209554"&gt;@Bintang18&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;The CATT() function creates a string which you then assign to a variable (the variable left from the equal sign).&lt;/P&gt;
&lt;P&gt;If this variable is not long enough to hold the generated string then you get a log message as above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add at the very beginning of your data step a LENGTH statement&amp;nbsp; defining a length long enough for the generated string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  id=25;
run;

data want;
  length newvar $20;
  set have;
  newvar=catt('A200_2018_',id);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 May 2018 02:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/461751#M117491</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-12T02:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: combine numeric&amp;string to new var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/462036#M117551</link>
      <description>Thank you all for helping me out, it worked after I edit var length. Shirley</description>
      <pubDate>Mon, 14 May 2018 13:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-numeric-amp-string-to-new-var/m-p/462036#M117551</guid>
      <dc:creator>Bintang18</dc:creator>
      <dc:date>2018-05-14T13:38:26Z</dc:date>
    </item>
  </channel>
</rss>

