<?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: How to find the first negative value in every 20 quarters with at least 50% of the value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/733964#M228691</link>
    <description>&lt;P&gt;What happens after observation 20?&lt;/P&gt;
&lt;P&gt;Untested as no usable data was supplied, but something like this should work, provided the data is sorted.&lt;/P&gt;
&lt;P&gt;Adapt to your needs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;&lt;BR /&gt;&amp;nbsp; set HAVE;
&amp;nbsp; if MARK=1 and ^MARK then do;
&amp;nbsp; &amp;nbsp; FIRST_PERIOD=PERIOD;
&amp;nbsp; &amp;nbsp; FIRST_ACC=ACC;
&amp;nbsp; end;
 &amp;nbsp;else&amp;nbsp;if -ACC &amp;gt;&amp;nbsp;FIRST_ACC/2 and PERIOD &amp;lt;= FIRST_PERIOD+20 then FIRST_NEG_50PCT=1;
  retain FIRST:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Apr 2021 21:36:55 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-04-14T21:36:55Z</dc:date>
    <item>
      <title>How to find the first negative value in every specific quarters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/733917#M228687</link>
      <description>&lt;P&gt;I want to find the first negative observation during the 20 quarters following "mark = 1" that has at least 50% of the (mark=1)'s "acc".&lt;/P&gt;&lt;P&gt;In this dataset, datadate is composed of five digits = (year * 10) + quarter. Thus, there are four quarters in each year. For example, Obs. 1 shows the 1st Quarter in Year 1989.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
set test1;
period + 1;
by gvkey datadate;
if first.gvkey then period = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2; 
	set test1;
	if mark = 1 then do;
    first_period = period;
    first_acc = acc;
  	end;

  	else 
	do;
	if -acc &amp;gt; first_acc/2 and period &amp;lt;= first_period + 20 then first_neg_50pct = 1;
  	retain first:;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 06:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/733917#M228687</guid>
      <dc:creator>latte747</dc:creator>
      <dc:date>2021-04-18T06:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the first negative value in every 20 quarters with at least 50% of the value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/733961#M228690</link>
      <description>&lt;P&gt;Does Name ever change within the values of Gvkey? If so, how does that effect the process? If name has not impact on the process then please say so. Otherwise the problem description could be incomplete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What if a negative value meets the criteria for previous "mark=1" group? Consider in your example below if the 7th observation were actually the 8th and the value for the reordered data had ACC = 0.1 or such . Then the value meets the criteria for the "mark=1" that started on obs=1: it is within 20 quarters and magnitude is large enough for the previous mark group but not the one with Acc=0.1&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 21:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/733961#M228690</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-14T21:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the first negative value in every 20 quarters with at least 50% of the value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/733964#M228691</link>
      <description>&lt;P&gt;What happens after observation 20?&lt;/P&gt;
&lt;P&gt;Untested as no usable data was supplied, but something like this should work, provided the data is sorted.&lt;/P&gt;
&lt;P&gt;Adapt to your needs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;&lt;BR /&gt;&amp;nbsp; set HAVE;
&amp;nbsp; if MARK=1 and ^MARK then do;
&amp;nbsp; &amp;nbsp; FIRST_PERIOD=PERIOD;
&amp;nbsp; &amp;nbsp; FIRST_ACC=ACC;
&amp;nbsp; end;
 &amp;nbsp;else&amp;nbsp;if -ACC &amp;gt;&amp;nbsp;FIRST_ACC/2 and PERIOD &amp;lt;= FIRST_PERIOD+20 then FIRST_NEG_50PCT=1;
  retain FIRST:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 21:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/733964#M228691</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-04-14T21:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the first negative value in every 20 quarters with at least 50% of the value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/733965#M228692</link>
      <description>&lt;P&gt;Thank you for your interest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Name has no impact, so only gvkey matters.&lt;/P&gt;&lt;P&gt;2. If a negative value meets the previous criteria as well, then I'd like to count it twice. But, since "first_negative_50%" is an indicator variable, it would be simply "1".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 22:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/733965#M228692</guid>
      <dc:creator>latte747</dc:creator>
      <dc:date>2021-04-14T22:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the first negative value in every 20 quarters with at least 50% of the value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/734079#M228719</link>
      <description>&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, how can I extract only "the first" negative value?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 03:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/734079#M228719</guid>
      <dc:creator>latte747</dc:creator>
      <dc:date>2021-04-15T03:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the first negative value in every 20 quarters with at least 50% of the value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/734110#M228736</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; how can I extract only "the first" negative value?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can set a flag when you found a value. Don't forget to &lt;EM&gt;retain&lt;/EM&gt; that flag.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 06:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-negative-value-in-every-specific-quarters/m-p/734110#M228736</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-04-15T06:02:32Z</dc:date>
    </item>
  </channel>
</rss>

