<?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: Problem to Organize a Table in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Problem-to-Organize-a-Table/m-p/728520#M35328</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the post of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;has given you the right response. I've also seen that you liked it. It's even better to mark it as a solution!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With my post I just want to make you aware that there exists a procedure in SAS/ETS that directly supports your [t-31] logic. It's PROC TIMEDATA. Have a look at the program below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC TIMEDATA data=sashelp.citiday out=_NULL_ /*PRINT=(ARRAYS)*/ OUTARRAY=wanted1;
	outarrays dtbd3m_31 my_dtbd3m;
	/*by by_var*/;
	id date interval=day accumulate=total format=date9.;
	var dtbd3m;
       do t = 32 to dim(dtbd3m);
	    dtbd3m_31[t] = dtbd3m[t-31];
        if dtbd3m_31[t]&amp;gt;6 then my_dtbd3m[t]=dtbd3m[t]; else my_dtbd3m[t]=-99999;
       end;
run; QUIT;

data wanted1; 
 set wanted1; 
 if _N_&amp;lt;32 then delete; 
 if my_dtbd3m=-99999 then delete; 
run;

PROC SQL noprint;
 create table wanted2 as
 select *
 from wanted1
 where date IN (select date from sashelp.citiday);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get the same 411 rows in return as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;of course.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Mar 2021 18:39:38 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2021-03-23T18:39:38Z</dc:date>
    <item>
      <title>Problem to Organize a Table</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Problem-to-Organize-a-Table/m-p/728485#M35316</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am having an issue with a research paper I am into. I have created&amp;nbsp; a table with proc sql, which displays several variables, among which price and date. How can I keep only the rows for which the price value at t-31 (therefore 31 days before the value reported in the date column) is greater than 5?&lt;/P&gt;&lt;P&gt;I need something like prc(t-31)&amp;gt;5.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this may sound trivial, but I am really stuck in this issue.&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Riccardo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 16:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Problem-to-Organize-a-Table/m-p/728485#M35316</guid>
      <dc:creator>RDellaVilla</dc:creator>
      <dc:date>2021-03-23T16:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem to Organize a Table</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Problem-to-Organize-a-Table/m-p/728488#M35318</link>
      <description>&lt;P&gt;You can merge the data set with itself (31 days earlier) in PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example using SAS dataset SASHELP.CITYDAY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as select a.*
        from sashelp.citiday as a left join sashelp.citiday as b
        on b.date=(a.date-31) where b.dtbd3m&amp;gt;6;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Mar 2021 16:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Problem-to-Organize-a-Table/m-p/728488#M35318</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-23T16:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Problem to Organize a Table</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Problem-to-Organize-a-Table/m-p/728520#M35328</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the post of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;has given you the right response. I've also seen that you liked it. It's even better to mark it as a solution!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With my post I just want to make you aware that there exists a procedure in SAS/ETS that directly supports your [t-31] logic. It's PROC TIMEDATA. Have a look at the program below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC TIMEDATA data=sashelp.citiday out=_NULL_ /*PRINT=(ARRAYS)*/ OUTARRAY=wanted1;
	outarrays dtbd3m_31 my_dtbd3m;
	/*by by_var*/;
	id date interval=day accumulate=total format=date9.;
	var dtbd3m;
       do t = 32 to dim(dtbd3m);
	    dtbd3m_31[t] = dtbd3m[t-31];
        if dtbd3m_31[t]&amp;gt;6 then my_dtbd3m[t]=dtbd3m[t]; else my_dtbd3m[t]=-99999;
       end;
run; QUIT;

data wanted1; 
 set wanted1; 
 if _N_&amp;lt;32 then delete; 
 if my_dtbd3m=-99999 then delete; 
run;

PROC SQL noprint;
 create table wanted2 as
 select *
 from wanted1
 where date IN (select date from sashelp.citiday);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get the same 411 rows in return as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;of course.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 18:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Problem-to-Organize-a-Table/m-p/728520#M35328</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-03-23T18:39:38Z</dc:date>
    </item>
  </channel>
</rss>

