<?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: Need Data Step Solution in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480792#M124275</link>
    <description>&lt;P&gt;Thanks a lot Sir, One question on your ans. if there is other numerical variable which contains negative and positive values then how your code will recognize that we need work on balance?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jul 2018 13:43:49 GMT</pubDate>
    <dc:creator>Aman4SAS</dc:creator>
    <dc:date>2018-07-24T13:43:49Z</dc:date>
    <item>
      <title>Need Data Step Solution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480763#M124262</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dear Friends,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to help to find the solution for my problem.(If its possible in SAS)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Acc_no &amp;nbsp;date &amp;nbsp;balances&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; 3000&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; -200 This date required&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp;-350&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; &amp;nbsp;6 &amp;nbsp; &amp;nbsp;1000&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; 7 &amp;nbsp; &amp;nbsp; &amp;nbsp;5000&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp;8000&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp;9 &amp;nbsp; &amp;nbsp; -200 This date required&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp;10 &amp;nbsp; &amp;nbsp;-500&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; 11 &amp;nbsp; -1000&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; 12 &amp;nbsp; &amp;nbsp;-1500&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp; 13 &amp;nbsp; -2000&lt;/P&gt;
&lt;P&gt;like this i have multiple accounts i need latest date when balances start being negative. I have ticked on the date which required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 11:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480763#M124262</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2018-07-24T11:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need Data Step Solution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480771#M124265</link>
      <description>&lt;P&gt;Use by-group processing for the accounts, a retained variable, and set it everytime lag(balances) is positive and balances is negative.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For code, please provide your example data in a readily usable form (data step with datalines).&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 11:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480771#M124265</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-24T11:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need Data Step Solution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480773#M124266</link>
      <description>&lt;P&gt;Hope this helps:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dsd dlm=',' missover;
input Acc_no  date  balances;
datalines;
101,1,2000
101,2,3000
101,3,0
101,4,-200
101,5,-350
101,6,1000
101,7,5000
101,8,8000
101,9,-200
101,10,-500
101,11,-1000
101,12,-1500
101,13,-2000
;
run;
proc sort data=have;
by Acc_no  date;
run;

data want;
set have;
Lag_Bal=lag(balances);
if balances&amp;lt;0 and lag_Bal&amp;gt;=0 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jul 2018 12:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480773#M124266</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-07-24T12:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need Data Step Solution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480774#M124267</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Acc_no  date  balances;
cards;
101    1     2000
101    2     3000
101    3     0
101    4     -200 This date required
101    5    -350
101    6    1000
101   7      5000
101  8      8000
101  9     -200 This date required
101  10    -500
101   11   -1000
101   12    -1500
101   13   -2000
;
run;
data temp;
 set have;
 sign=sign(balances);
run;
data want;
 set temp;
 by acc_no sign notsorted;
 if sign=-1 and first.sign;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jul 2018 12:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480774#M124267</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-07-24T12:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need Data Step Solution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480792#M124275</link>
      <description>&lt;P&gt;Thanks a lot Sir, One question on your ans. if there is other numerical variable which contains negative and positive values then how your code will recognize that we need work on balance?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 13:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480792#M124275</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2018-07-24T13:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need Data Step Solution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480794#M124276</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/39317"&gt;@Aman4SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks a lot Sir, One question on your ans. if there is other numerical variable which contains negative and positive values then how your code will recognize that we need work on balance?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The crucial step is this one:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
 set have;
 sign=sign(balances);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here, sign is derived from balances, and nothing else.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 13:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480794#M124276</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-24T13:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need Data Step Solution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480799#M124280</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/39317"&gt;@Aman4SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks a lot Sir, One question on your ans. if there is other numerical variable which contains negative and positive values then how your code will recognize that we need work on balance?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is somewhat poor form to start adding additional requirements after working solutions have been provided. You would have to provide additional example data, descriptions of all of the rules involved and example of desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You provide no data and no actual rules. You have to provide exactly how "other numerical variable" values impact the entire problem. Depending on your actual additional rules the initial provided solutions may require little modification or drastically more coding, but without details it is hard to say.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 14:15:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Data-Step-Solution/m-p/480799#M124280</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-24T14:15:08Z</dc:date>
    </item>
  </channel>
</rss>

