<?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: select a condition and update the value of the other existing variable before creating new varia in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/select-a-condition-and-update-the-value-of-the-other-existing/m-p/570546#M160898</link>
    <description>&lt;P&gt;Thank you and I am able to find what is wrong in my previous code. Thank you so much.&lt;/P&gt;&lt;P&gt;DATA have;&lt;BR /&gt;input a $ b $ c $;&lt;BR /&gt;datalines;&lt;BR /&gt;0 2 7&lt;BR /&gt;1 5 2&lt;BR /&gt;1 7 3&lt;BR /&gt;0 3 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;/P&gt;&lt;P&gt;if a="1" then&lt;BR /&gt;DO;&lt;BR /&gt;select(b);&lt;BR /&gt;when ("1") b="0.07";&lt;BR /&gt;when ("2") b="0.14";&lt;BR /&gt;when ("3") b="0.36";&lt;BR /&gt;when ("4") b="0.64";&lt;BR /&gt;when ("5") b="1";&lt;BR /&gt;when ("6") b="3";&lt;BR /&gt;when ("7") b="5";&lt;BR /&gt;otherwise;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;select(c);&lt;BR /&gt;when ("1") c="0.07";&lt;BR /&gt;when ("2") c="0.14";&lt;BR /&gt;when ("3") c="0.36";&lt;BR /&gt;when ("4") c="0.64";&lt;BR /&gt;when ("5") c="1";&lt;BR /&gt;when ("6") c="3";&lt;BR /&gt;when ("7") c="5";&lt;BR /&gt;otherwise;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;e=b+c;&lt;BR /&gt;d=put(e,4.2);&lt;BR /&gt;drop e;&lt;BR /&gt;END;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jul 2019 13:27:31 GMT</pubDate>
    <dc:creator>CHL0320</dc:creator>
    <dc:date>2019-07-02T13:27:31Z</dc:date>
    <item>
      <title>select a condition and update the value of the other existing variable before creating new variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-a-condition-and-update-the-value-of-the-other-existing/m-p/570391#M160827</link>
      <description>&lt;P&gt;Hi Community;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a solution to select the condition on the first character variable then updates the value of the other character variables before creating the final character variable. For example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;DATA have;&lt;BR /&gt;input a $ b $ c $;&lt;BR /&gt;datalines;&lt;BR /&gt;0 2 7&lt;BR /&gt;1 5 2&lt;BR /&gt;1 7 3&lt;BR /&gt;0 3 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The request is if a is 1 then update the value in b and c as&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;when&amp;nbsp; a="1" and then&amp;nbsp;when b or c=1&amp;nbsp; then the new value of&amp;nbsp; b or c=0.07;&lt;/DIV&gt;&lt;DIV&gt;when&amp;nbsp; a="1" and then&amp;nbsp;when b or c=2 then the new value of&amp;nbsp; b or c=0.14;&lt;/DIV&gt;&lt;DIV&gt;when&amp;nbsp; a="1" and then&amp;nbsp;when b or c=3&amp;nbsp; then the new value of&amp;nbsp; b or c=0.36;&lt;/DIV&gt;&lt;DIV&gt;when&amp;nbsp; a="1" and then&amp;nbsp;when b or c=4&amp;nbsp; then the new value of&amp;nbsp; b or c=0.64;&lt;/DIV&gt;&lt;DIV&gt;when&amp;nbsp; a="1" and then&amp;nbsp;when b or c=5&amp;nbsp; then the new value of&amp;nbsp; b or c=1;&lt;/DIV&gt;&lt;DIV&gt;when&amp;nbsp; a="1" and then&amp;nbsp;when b or c=6&amp;nbsp; then the new value of&amp;nbsp; b or c=3;&lt;/DIV&gt;&lt;DIV&gt;when&amp;nbsp; a="1" and then&amp;nbsp;when b or c=7&amp;nbsp; then the new value of&amp;nbsp; b or c=5;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The final step is to create a new character variable d as the sum of b and c.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Therefore the wanted table will be like&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;a&amp;nbsp; &amp;nbsp; &amp;nbsp; b&amp;nbsp; &amp;nbsp; &amp;nbsp; c&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d&lt;/DIV&gt;&lt;DIV&gt;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/DIV&gt;&lt;DIV&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; 0.14&amp;nbsp; &amp;nbsp;1.14&lt;/DIV&gt;&lt;DIV&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp;0.36&amp;nbsp; &amp;nbsp;5.36&lt;/DIV&gt;&lt;DIV&gt;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;All the variables are character variables.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you for your help.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 01 Jul 2019 20:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-a-condition-and-update-the-value-of-the-other-existing/m-p/570391#M160827</guid>
      <dc:creator>CHL0320</dc:creator>
      <dc:date>2019-07-01T20:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: select a condition and update the value of the other existing variable before creating new varia</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-a-condition-and-update-the-value-of-the-other-existing/m-p/570408#M160833</link>
      <description>&lt;P&gt;This doesn't look particularly difficult.&amp;nbsp; Can you post the code you've attempted, and describe what didn't work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Read the doc on IF/THEN/ELSE and SELECT/WHEN/OTHERWISE.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 23:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-a-condition-and-update-the-value-of-the-other-existing/m-p/570408#M160833</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-07-01T23:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: select a condition and update the value of the other existing variable before creating new varia</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-a-condition-and-update-the-value-of-the-other-existing/m-p/570546#M160898</link>
      <description>&lt;P&gt;Thank you and I am able to find what is wrong in my previous code. Thank you so much.&lt;/P&gt;&lt;P&gt;DATA have;&lt;BR /&gt;input a $ b $ c $;&lt;BR /&gt;datalines;&lt;BR /&gt;0 2 7&lt;BR /&gt;1 5 2&lt;BR /&gt;1 7 3&lt;BR /&gt;0 3 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;/P&gt;&lt;P&gt;if a="1" then&lt;BR /&gt;DO;&lt;BR /&gt;select(b);&lt;BR /&gt;when ("1") b="0.07";&lt;BR /&gt;when ("2") b="0.14";&lt;BR /&gt;when ("3") b="0.36";&lt;BR /&gt;when ("4") b="0.64";&lt;BR /&gt;when ("5") b="1";&lt;BR /&gt;when ("6") b="3";&lt;BR /&gt;when ("7") b="5";&lt;BR /&gt;otherwise;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;select(c);&lt;BR /&gt;when ("1") c="0.07";&lt;BR /&gt;when ("2") c="0.14";&lt;BR /&gt;when ("3") c="0.36";&lt;BR /&gt;when ("4") c="0.64";&lt;BR /&gt;when ("5") c="1";&lt;BR /&gt;when ("6") c="3";&lt;BR /&gt;when ("7") c="5";&lt;BR /&gt;otherwise;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;e=b+c;&lt;BR /&gt;d=put(e,4.2);&lt;BR /&gt;drop e;&lt;BR /&gt;END;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 13:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-a-condition-and-update-the-value-of-the-other-existing/m-p/570546#M160898</guid>
      <dc:creator>CHL0320</dc:creator>
      <dc:date>2019-07-02T13:27:31Z</dc:date>
    </item>
  </channel>
</rss>

