<?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: Deriving a new variable based on other variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Deriving-a-new-variable-based-on-other-variables/m-p/609848#M17987</link>
    <description>&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;     
input Date: ddmmyy10. ID Account Closed$ Value:dollar10.;
cards;
01/01/2019 1 1 Y $10 
25/12/2018 1 1 Y $72 
22/11/2018 1 1 Y $90 
20/11/2017 1 1 Y $87 
;

proc sort data=have;
by id account descending date ;
run;

data want;
set have;
by id account descending date;
if first.account and Closed='Y' then New_Value=0;
else New_Value=Value;
format date date9. value New_Value dollar10.;;
run;
              &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 06 Dec 2019 03:02:53 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2019-12-06T03:02:53Z</dc:date>
    <item>
      <title>Deriving a new variable based on other variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Deriving-a-new-variable-based-on-other-variables/m-p/609844#M17985</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with 5 variables: Date, ID, Account, Closed, Value and I am wanting to create a new variable: New_Value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically New_Value is just the Value of the Account except if the Account for that specific ID has a Closed indicator of 'Y' &lt;STRONG&gt;AND&amp;nbsp;&lt;/STRONG&gt;is the latest recorded instance for that Account based on the Date, then I would like to change the New_Value for this row to 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Example, New_Value should look like this:&lt;BR /&gt;&lt;BR /&gt;Date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; ID &amp;nbsp; &amp;nbsp; &amp;nbsp; Account&amp;nbsp; Closed &amp;nbsp;&amp;nbsp; Value &amp;nbsp; &amp;nbsp; New_Value&lt;/P&gt;&lt;P&gt;01/01/2019 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Y &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; $10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $0&lt;/P&gt;&lt;P&gt;25/12/2018 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Y &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; $72 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $72&lt;/P&gt;&lt;P&gt;22/11/2018 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Y &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; $90 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $90&lt;/P&gt;&lt;P&gt;20/11/2017 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Y &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; $87 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $87&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are many accounts per ID with each having multiple dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 02:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Deriving-a-new-variable-based-on-other-variables/m-p/609844#M17985</guid>
      <dc:creator>Bounce</dc:creator>
      <dc:date>2019-12-06T02:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Deriving a new variable based on other variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Deriving-a-new-variable-based-on-other-variables/m-p/609848#M17987</link>
      <description>&lt;P&gt;please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;     
input Date: ddmmyy10. ID Account Closed$ Value:dollar10.;
cards;
01/01/2019 1 1 Y $10 
25/12/2018 1 1 Y $72 
22/11/2018 1 1 Y $90 
20/11/2017 1 1 Y $87 
;

proc sort data=have;
by id account descending date ;
run;

data want;
set have;
by id account descending date;
if first.account and Closed='Y' then New_Value=0;
else New_Value=Value;
format date date9. value New_Value dollar10.;;
run;
              &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Dec 2019 03:02:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Deriving-a-new-variable-based-on-other-variables/m-p/609848#M17987</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-12-06T03:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Deriving a new variable based on other variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Deriving-a-new-variable-based-on-other-variables/m-p/609849#M17988</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Date    :ddmmyy10.   ID       Account  Closed $   Value : dollar3. ;*   New_Value ;
format date date9.;
cards;
01/01/2019          1             1            Y          $10             $0
25/12/2018          1             1            Y          $72             $72
22/11/2018          1             1            Y          $90             $90
20/11/2017          1             1            Y          $87             $87
;

proc sql;
create table want as
select * , ifn(max(date)=date and closed='Y',0,value) as New_value
from have
group by id, account
order by id,account,date desc;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Dec 2019 03:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Deriving-a-new-variable-based-on-other-variables/m-p/609849#M17988</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-06T03:09:48Z</dc:date>
    </item>
  </channel>
</rss>

