<?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: Adding some numbers to variable and calculating the length of variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681768#M24053</link>
    <description>Thank you very much</description>
    <pubDate>Fri, 04 Sep 2020 22:36:44 GMT</pubDate>
    <dc:creator>Nini1</dc:creator>
    <dc:date>2020-09-04T22:36:44Z</dc:date>
    <item>
      <title>Adding some numbers to variable and calculating the length of variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681754#M24049</link>
      <description>&lt;P&gt;Hello everyone, I'm new SAS user and could you please help me to solve some problem? how can I add some number to the existing variable? e.g. in this table it is shown that I added '25' to all the number in variable 'num' and got a new variable 'number'. One more thing, how can I calculate how many elements does each data have? e.g. 2364 has 4, 8467 again 4,&amp;nbsp;253679 has 6 and so on . So I want to have another column that will reflect the length of each data. I used function length but it did not work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you in advance&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;num&lt;/TD&gt;&lt;TD&gt;number&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2365&lt;/TD&gt;&lt;TD&gt;252365&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8467&lt;/TD&gt;&lt;TD&gt;258467&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;253679&lt;/TD&gt;&lt;TD&gt;25253679&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4533&lt;/TD&gt;&lt;TD&gt;254533&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 04 Sep 2020 20:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681754#M24049</guid>
      <dc:creator>Nini1</dc:creator>
      <dc:date>2020-09-04T20:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Adding some numbers to variable and calculating the length of variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681757#M24050</link>
      <description>&lt;P&gt;Assuming the original variable is a character variable (is it?), this will prepend the characters '25' in front of it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;number=cats('25',num);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Actually, the above ought to work even if NUM is numeric and not character, but NUMBER will always be character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as how many elements each string has, you can use the LENGTH() function.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 20:59:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681757#M24050</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-04T20:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Adding some numbers to variable and calculating the length of variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681759#M24052</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input num;*	number;
cards;
2365	252365
8467	258467
253679	25253679
4533	254533
;

data want;
 set have;
 new_num=input(cats('25',num),32.);
 length=lengthn(cats(num));
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Sep 2020 21:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681759#M24052</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-09-04T21:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Adding some numbers to variable and calculating the length of variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681768#M24053</link>
      <description>Thank you very much</description>
      <pubDate>Fri, 04 Sep 2020 22:36:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681768#M24053</guid>
      <dc:creator>Nini1</dc:creator>
      <dc:date>2020-09-04T22:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Adding some numbers to variable and calculating the length of variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681803#M24060</link>
      <description>&lt;P&gt;Assuming it was always positive number.&lt;/P&gt;
&lt;PRE&gt;data have;
input num;
new= 25*10**(int(log10(num))+1) + num;
cards;
2365	252365
8467	258467
253679	25253679
4533	254533
;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 11:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-some-numbers-to-variable-and-calculating-the-length-of/m-p/681803#M24060</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-09-05T11:58:18Z</dc:date>
    </item>
  </channel>
</rss>

