<?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 prefix to observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298896#M62928</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   length var $10;
   var='1234567890';
run;
data want(rename=(var2=var));
   length var2 $14;
   set have;
   var2=cats('2222',var);
   drop var;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 16 Sep 2016 09:42:53 GMT</pubDate>
    <dc:creator>Oligolas</dc:creator>
    <dc:date>2016-09-16T09:42:53Z</dc:date>
    <item>
      <title>add prefix to observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298888#M62921</link>
      <description>&lt;P&gt;I am sure this is very simple guys, but i am struggling.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a data set with 1 variable (numeric), its 10 digits long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to at the same prefix to all observations (around 130,000 in total)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the prefix is numeric and is 4 digits long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;have: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1234567890&lt;/P&gt;&lt;P&gt;want: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;22221234567890&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;apologies if i am missing something obvious, but it has been an awfully long week so far...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;paul&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 08:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298888#M62921</guid>
      <dc:creator>pandhandj</dc:creator>
      <dc:date>2016-09-16T08:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: add prefix to observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298890#M62923</link>
      <description>&lt;P&gt;Well, if they are all 10 and you want the 2222, then you can just do:&lt;/P&gt;
&lt;P&gt;value=value + 22220000000000;&lt;/P&gt;
&lt;P&gt;I think I got the right number of zeroes there - adjust as per your testing &lt;span class="lia-unicode-emoji" title=":monkey_face:"&gt;🐵&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively if they are not all 10, then its probably simpler to convert to text, append then convert back to number:&lt;BR /&gt;value=put(cats("2222",input(value,best.),best.);&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 09:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298890#M62923</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-09-16T09:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: add prefix to observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298891#M62924</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;if you always have 10 digits, you could simply add 22220000000000 to your value.&lt;/P&gt;&lt;P&gt;if not, you can convert it to char, add the prefix and reconvert to numeric, like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   var=1234567890;
run;
data want;
   length want1 want2 8;
   set have;
   want1=var+22220000000000;
   want2=input('2222'||strip(put(var,best31.)),best31.);
   format want1 want2 16.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 09:23:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298891#M62924</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2016-09-16T09:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: add prefix to observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298894#M62926</link>
      <description>Guys, thanks for the responses.&lt;BR /&gt;&lt;BR /&gt;my apologies, but i have just realized that my observations are actually Character format, sorry.&lt;BR /&gt;&lt;BR /&gt;i cant get your suggestions to work and i think this is why. Could you rethink please?&lt;BR /&gt;&lt;BR /&gt;thanks again.</description>
      <pubDate>Fri, 16 Sep 2016 09:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298894#M62926</guid>
      <dc:creator>pandhandj</dc:creator>
      <dc:date>2016-09-16T09:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: add prefix to observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298895#M62927</link>
      <description>&lt;P&gt;that is &amp;nbsp;called concatention&lt;/P&gt;&lt;P&gt;Have a look at the CATx functions (where x could be X S T or not present)&lt;/P&gt;&lt;P&gt;As stated you might want&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;new_string = cats( '222', old_string ) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 09:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298895#M62927</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2016-09-16T09:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: add prefix to observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298896#M62928</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   length var $10;
   var='1234567890';
run;
data want(rename=(var2=var));
   length var2 $14;
   set have;
   var2=cats('2222',var);
   drop var;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Sep 2016 09:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298896#M62928</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2016-09-16T09:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: add prefix to observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298899#M62931</link>
      <description>thanks to all...I'm cooking with gas now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 16 Sep 2016 09:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/298899#M62931</guid>
      <dc:creator>pandhandj</dc:creator>
      <dc:date>2016-09-16T09:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: add prefix to observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/299077#M62988</link>
      <description>&lt;PRE&gt;
If you want numeric variable be that, try PICTURE:



proc format;
picture fmt
 low-high='00000000000000' (prefix='2222');
run;
data have;
have=1234567890;
format have fmt.;
run;

&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Sep 2016 04:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-prefix-to-observations/m-p/299077#M62988</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-17T04:05:13Z</dc:date>
    </item>
  </channel>
</rss>

