<?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: Assigning value of one variable to  other variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/566948#M159395</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $ points;
datalines;
x 10
y 5
z 20
;

data want;
set have;
_points = lag(points);
if name = 'y' then points = points + _points;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 18 Jun 2019 16:03:19 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-06-18T16:03:19Z</dc:date>
    <item>
      <title>Assigning value of one variable to  other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/566937#M159392</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a dataset like below&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Points&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;z&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to add the points of x to y, (result dataset should be like below)&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Points&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;z&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can any one suggest me on this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 15:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/566937#M159392</guid>
      <dc:creator>sg_kr</dc:creator>
      <dc:date>2019-06-18T15:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning value of one variable to  other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/566948#M159395</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $ points;
datalines;
x 10
y 5
z 20
;

data want;
set have;
_points = lag(points);
if name = 'y' then points = points + _points;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jun 2019 16:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/566948#M159395</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-18T16:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning value of one variable to  other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/566955#M159400</link>
      <description>&lt;P&gt;Thanks for Rapid response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this will work only when the y record is next to x.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if i have any other record between x and y , it wont work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Points&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;z&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want like below.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Points&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;z&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in my case, i dont have records next to each other, i need to capture the value of one record based on the name and summ it other record based on name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 16:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/566955#M159400</guid>
      <dc:creator>sg_kr</dc:creator>
      <dc:date>2019-06-18T16:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning value of one variable to  other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/566991#M159411</link>
      <description>&lt;P&gt;Then we do not use lag(), but a retained variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
retain _points;
if name = 'x' then _points = points;
if name = 'y' then points = points + _points;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jun 2019 18:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/566991#M159411</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-18T18:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning value of one variable to  other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/567282#M159508</link>
      <description>thanks.&lt;BR /&gt;but i am getting . value in the points for below line&lt;BR /&gt;if name = 'y' then points = points + _points;&lt;BR /&gt;</description>
      <pubDate>Wed, 19 Jun 2019 14:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/567282#M159508</guid>
      <dc:creator>sg_kr</dc:creator>
      <dc:date>2019-06-19T14:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning value of one variable to  other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/567304#M159520</link>
      <description>&lt;P&gt;If there are situations with missing values, use the sum() function in place of a simple addition.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 14:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/567304#M159520</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-19T14:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning value of one variable to  other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/567576#M159627</link>
      <description>&lt;P&gt;yes, i did .&lt;/P&gt;&lt;P&gt;but no use&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 11:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/567576#M159627</guid>
      <dc:creator>sg_kr</dc:creator>
      <dc:date>2019-06-20T11:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning value of one variable to  other variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/567577#M159628</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215304"&gt;@sg_kr&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;yes, i did .&lt;/P&gt;
&lt;P&gt;but no use&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which only means that all arguments to the sum() function are missing. If you want to set zero in such cases, add a single zero as argument to the function.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 11:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-value-of-one-variable-to-other-variable/m-p/567577#M159628</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-20T11:21:45Z</dc:date>
    </item>
  </channel>
</rss>

