<?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 numbers depending on a test to a column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-numbers-depending-on-a-test-to-a-column/m-p/690910#M210218</link>
    <description>Awesome, that's exactly what I needed! Thanks so much.</description>
    <pubDate>Mon, 12 Oct 2020 09:05:08 GMT</pubDate>
    <dc:creator>CIG21</dc:creator>
    <dc:date>2020-10-12T09:05:08Z</dc:date>
    <item>
      <title>Adding numbers depending on a test to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-numbers-depending-on-a-test-to-a-column/m-p/690887#M210207</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I am having this sample datasets which contains values and their units (K stands for ten thousands, M for millions). My goal is to have a new table (want) that adds the zeros, depending on K or M, to the value column variables and shows the value as proper number. I tried it with the below code but it did not work (did not get an error either&amp;nbsp;but it didn't change anything).&lt;/P&gt;&lt;P&gt;In the end, the table want should ideally look like this (tips on how to remove the redudandant unit columns are also&amp;nbsp;appreciated):&lt;/P&gt;&lt;P&gt;"value&lt;/P&gt;&lt;P&gt;10000&lt;/P&gt;&lt;P&gt;15000&lt;/P&gt;&lt;P&gt;19000000&lt;/P&gt;&lt;P&gt;4000000"&lt;/P&gt;&lt;PRE&gt;data example;
input value unit$;
datalines;
10 K
15 K
19 M
4 M
;
run;

data want;
set example;
if unit ="K" then value=value+000;
else value=value+000000;
run;&lt;/PRE&gt;&lt;P&gt;Any ideas on how I could achieve that? Thanks already in advance! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 06:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-numbers-depending-on-a-test-to-a-column/m-p/690887#M210207</guid>
      <dc:creator>CIG21</dc:creator>
      <dc:date>2020-10-12T06:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Adding numbers depending on a test to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-numbers-depending-on-a-test-to-a-column/m-p/690892#M210210</link>
      <description>&lt;P&gt;As far as I know "adding zeros" means multiplying by...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=unit);
 set example;
 if unit ="K" then value=value*1000;
                   else value=value*1000000;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 06:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-numbers-depending-on-a-test-to-a-column/m-p/690892#M210210</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-10-12T06:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Adding numbers depending on a test to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-numbers-depending-on-a-test-to-a-column/m-p/690897#M210213</link>
      <description>&lt;P&gt;With numeric data, 000 is equal to 0, so your addition statements do in effect nothing. You need to multiply.&lt;/P&gt;
&lt;P&gt;If k stands fo decimal "kilo", multiply by 1000, but if it stands for IT K (note the capital letter), multiply by 1024. Similarly, m should be multiplied by 1000000, but M by 1024*1024.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 07:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-numbers-depending-on-a-test-to-a-column/m-p/690897#M210213</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-12T07:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Adding numbers depending on a test to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-numbers-depending-on-a-test-to-a-column/m-p/690910#M210218</link>
      <description>Awesome, that's exactly what I needed! Thanks so much.</description>
      <pubDate>Mon, 12 Oct 2020 09:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-numbers-depending-on-a-test-to-a-column/m-p/690910#M210218</guid>
      <dc:creator>CIG21</dc:creator>
      <dc:date>2020-10-12T09:05:08Z</dc:date>
    </item>
  </channel>
</rss>

