<?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: Eliminate stocks that do not have continuous past 22 days returns data in a particular month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/406355#M98936</link>
    <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;Your code was helpful. Thanks a bunch.&lt;/P&gt;</description>
    <pubDate>Sun, 22 Oct 2017 11:07:09 GMT</pubDate>
    <dc:creator>ivanpersie</dc:creator>
    <dc:date>2017-10-22T11:07:09Z</dc:date>
    <item>
      <title>Eliminate stocks that do not have continuous past 22 days returns data in a particular month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/405092#M98508</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;
&lt;P&gt;I am sorting stock market data. Part of the process is to eliminate stocks that do not have continuous past 22 days daily returns data in a particular month. How can i code this down? I only wanna stay with stocks with that have data for continuous 22 days for every month. Please find attached data file&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 04:07:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/405092#M98508</guid>
      <dc:creator>ivanpersie</dc:creator>
      <dc:date>2017-10-18T04:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate stocks that do not have continuous past 22 days returns data in a particular month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/405101#M98513</link>
      <description>&lt;P&gt;Try PROC TIMESERIES&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 04:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/405101#M98513</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-18T04:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate stocks that do not have continuous past 22 days returns data in a particular month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/405102#M98514</link>
      <description>&lt;P&gt;Give a small program to generate the sample data next time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  do DATE=1 to 1000;
    do STOCKNO=1 to 200;
      VAL=( ranuni(0)&amp;lt;.96 );
      output;
     end;
  end;
  format DATE date9.; 
run;
proc sort data=HAVE out=SORTED;
  by STOCKNO DATE;
run;
data MARK_VALID; 
  set SORTED;
  by STOCKNO ;
  if STOCKNO=lag(STOCKNO) and month(DATE)=month(lag(DATE)) and VAL then VALID+1;
  else VALID=0;
  if VALID=22;
run;
proc sql; 
  create table WANT as
  select a.* 
  from SORTED       a
         inner join
       MARK_VALID   b
          on  a.STOCKNO    =  b.STOCKNO
          and put(a.DATE,monyy.)=  put(b.DATE,monyy.)
  order by STOCKNO, DATE;
quit;
  
&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, 18 Oct 2017 04:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/405102#M98514</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-10-18T04:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate stocks that do not have continuous past 22 days returns data in a particular month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/405202#M98545</link>
      <description>&lt;P&gt;I checked your data, none of stock satisfy your condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='c:\temp\Forum_RI.csv' out=temp dbms=csv replace;
run;

proc sort data=temp(where=(date is not missing)) out=have;
 by stock date;
run;

data have1;
 set have;
 by stock date;
 yymm=intnx('month',date,0);
 if first.date;
 format yymm yymmn6.;
run;

data have2;
 set have1;
 by stock;
 dif=dif(date);
 if first.stock then dif=1;
run;
/*
proc sql;
create table have3 as
 select *
  from have2
   group by stock,yymm
    having sum(dif ne 1)=0;
quit;
*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Oct 2017 13:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/405202#M98545</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-10-18T13:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate stocks that do not have continuous past 22 days returns data in a particular month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/406354#M98935</link>
      <description>&lt;P&gt;Hi Ksharp. Thanks for your help. I really appreciate. Actually the data i gave you was a sample, so that's why probably it did not return data. Otherwise with the full data i have here, it all working. Thanks again.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2017 11:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/406354#M98935</guid>
      <dc:creator>ivanpersie</dc:creator>
      <dc:date>2017-10-22T11:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate stocks that do not have continuous past 22 days returns data in a particular month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/406355#M98936</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;Your code was helpful. Thanks a bunch.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2017 11:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminate-stocks-that-do-not-have-continuous-past-22-days/m-p/406355#M98936</guid>
      <dc:creator>ivanpersie</dc:creator>
      <dc:date>2017-10-22T11:07:09Z</dc:date>
    </item>
  </channel>
</rss>

