<?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 add condition at select statement in proc sql in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348848#M10364</link>
    <description>&lt;P&gt;If I want to calculate calendar month, how to apply this function?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 10 Apr 2017 19:41:49 GMT</pubDate>
    <dc:creator>Tiny_Kane</dc:creator>
    <dc:date>2017-04-10T19:41:49Z</dc:date>
    <item>
      <title>how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348711#M10350</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to two data sets look like below, and the patient ID is the unique key linking those two sets. I want a third dataset, which give me the patient ID, the minimun of treatment date which is 6 month prior to the index_date, the minimun of the treatment date which is within 6-month before and 6-month after the index_date, and the minumun of the treatment date which is 6-month after the index_date. If any type of minimun of treatment date is not existing, for instance, there is no treatment date 6-month prior to the index_date, then this value will be misisng. How can I write the query?&amp;nbsp; Thank you very much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="147"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;patient ID&lt;/TD&gt;
&lt;TD width="83"&gt;index_date&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;3/4/2009&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;8/16/2010&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;6/6/2011&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;7/4/2009&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;TABLE width="179"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;patient ID&lt;/TD&gt;
&lt;TD width="115"&gt;treatment_data&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;9/30/2008&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;10/11/2008&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;4/1/2009&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1/1/2010&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;9/30/2010&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;12/30/2009&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;5/1/2010&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;8/1/2011&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;10/13/2011&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;12/13/2011&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;6/8/2009&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;3/1/2010&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 14:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348711#M10350</guid>
      <dc:creator>Tiny_Kane</dc:creator>
      <dc:date>2017-04-10T14:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348754#M10352</link>
      <description>&lt;P&gt;I have not fully QCd the output since you don't show your desired results, but I think this is doing what you want based on my interpretation of your description.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data indexes;
format index_date date9.;
input patient index_date :mmddyy10.;
datalines;
1 3/4/2009
2 8/16/2010
3 6/6/2011
4 7/4/2009
;


data patients;
format treatment_date date9.;
input patient treatment_date :mmddyy10.;
datalines;
1 9/30/2008
1 10/11/2008
1 4/1/2009
2 1/1/2010
2 9/30/2010
3 12/30/2009
3 5/1/2010
3 8/1/2011
3 10/13/2011
3 12/13/2011
4 6/8/2009
4 3/1/2010
;


proc sql;
    CREATE TABLE want AS
    SELECT DISTINCT a.patient, 
           CASE WHEN min(a.treatment_date) &amp;gt;= intnx('month', b.index_date, -6) THEN min(a.treatment_date)
                ELSE .
           END AS min_treat format date9.,
           CASE WHEN max(a.treatment_date) &amp;lt;= intnx('month', b.index_date, 6) THEN max(a.treatment_date)
                ELSE .
           END AS max_treat format date9.
    FROM patients AS a
    LEFT JOIN indexes AS b
    ON a.patient = b.patient
    GROUP BY a.patient;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 15:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348754#M10352</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-10T15:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348801#M10358</link>
      <description>&lt;P&gt;Hi, thanks for your solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I think that's not what I am looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry that I might not describe clearly. Actually, for each patient, I need three flag variables, one is whether or not having treatment date 6 month prior to the index date, the seconde one is whether or not having treatment date within pre 6&amp;nbsp; month and post 6 month of index date, the third flag is whether or not having treatment date 6 month after the index date. Do you understand what I mean now?&amp;nbsp; Thank you very much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 17:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348801#M10358</guid>
      <dc:creator>Tiny_Kane</dc:creator>
      <dc:date>2017-04-10T17:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348814#M10359</link>
      <description>&lt;P&gt;I'm still not sure I understand, but what about the following to create the three flags you want? You can see the attached image where I checked the flags. If this isn't correct, it might help if you provide an example of the desired results.&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 DISTINCT a.patient,
           /* Flag 1:  having treatment date 6 month prior to the index date */
           min(a.treatment_date) &amp;lt; intnx('month', b.index_date, -6) AS flag1 'Has Treatment Earlier Than Six Mos Before Index',
           /* Flag 2: having treatment date within pre 6  month and post 6 month of index date */
           max(a.treatment_date BETWEEN intnx('month', b.index_date, -6) AND intnx('month', b.index_date, 6)) AS flag2 'Has Treatment Between Index +/- Six Mos',
           /* Flag 3: not having treatment date 6 month after the index date */
           max(a.treatment_date) &amp;gt; intnx('month', b.index_date, 6) AS flag3 'Has Treatment Later Than Six Mos After Index'
    FROM patients AS a
    LEFT JOIN indexes AS b
    ON a.patient = b.patient
    GROUP BY a.patient;
quit;

proc print label;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13687i7330DA2CC53B92B5/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;</description>
      <pubDate>Mon, 10 Apr 2017 17:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348814#M10359</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-10T17:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348815#M10360</link>
      <description>&lt;P&gt;This will count "months", you can assign other value based on the result.&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table period as
   select a.*, b.Index_date, intck('month',a.treatment_date,b.index_date) as months
   from patients as a left join indexes as b
        on a.patient=b.patient;
quit;&lt;/PRE&gt;
&lt;P&gt;However this does beg the question of the meaning of "months". Do you mean calendar measurement, where 31 March is one month from 1 April or do you mean "30 (or possibly 31) day intervals"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 17:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348815#M10360</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-10T17:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348842#M10362</link>
      <description>&lt;P&gt;Hi Collinelliot,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either one of the below data sets is what I desire to get. It can be listing the date or replacing the date by YES flag variables. The first table below is telling, for instance, the patientID=1 does not have any treatment history happenning 6 month before the index date, so the mindate_pre6month is missing or the flag is missing. The patientID=1 has treatment records happened between pre 6 month and post 6 month of index date, and among those records, the miniumen treatment date is 9/30/2008, so the second flag for patient=1 is YES.&lt;/P&gt;
&lt;P&gt;And I tried your code, it works. It gives me the second table. GREAT!! Thank you. By the way, if I want the first table below, how can I modifiy your code?&amp;nbsp; Thank you so much!&lt;/P&gt;
&lt;TABLE width="502"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;patient ID&lt;/TD&gt;
&lt;TD width="117"&gt;mindate_pre6month&lt;/TD&gt;
&lt;TD width="184"&gt;mindate_pre6month_post6month&lt;/TD&gt;
&lt;TD width="137"&gt;mindate_post6month&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;9/30/2008&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1/1/2010&lt;/TD&gt;
&lt;TD&gt;9/30/2010&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;12/30/2009&lt;/TD&gt;
&lt;TD&gt;8/1/2011&lt;/TD&gt;
&lt;TD&gt;12/13/2011&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;6/8/2009&lt;/TD&gt;
&lt;TD&gt;3/1/2010&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;TABLE width="502"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;patient ID&lt;/TD&gt;
&lt;TD width="117"&gt;flag1_pre6month&lt;/TD&gt;
&lt;TD width="184"&gt;flag2_pre6month_post6month&lt;/TD&gt;
&lt;TD width="137"&gt;flag3_post6month&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;yes&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;yes&lt;/TD&gt;
&lt;TD&gt;yes&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;yes&lt;/TD&gt;
&lt;TD&gt;yes&lt;/TD&gt;
&lt;TD&gt;yes&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;yes&lt;/TD&gt;
&lt;TD&gt;yes&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;TD&gt;…&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 19:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348842#M10362</guid>
      <dc:creator>Tiny_Kane</dc:creator>
      <dc:date>2017-04-10T19:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348844#M10363</link>
      <description>&lt;P&gt;Actually, I mean calendar month. Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 19:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348844#M10363</guid>
      <dc:creator>Tiny_Kane</dc:creator>
      <dc:date>2017-04-10T19:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348848#M10364</link>
      <description>&lt;P&gt;If I want to calculate calendar month, how to apply this function?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 19:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348848#M10364</guid>
      <dc:creator>Tiny_Kane</dc:creator>
      <dc:date>2017-04-10T19:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348850#M10365</link>
      <description>&lt;P&gt;I think given the two desired outcomes, I'd change the approach to the following.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data indexes;
    format index_date date9.;
    input patient index_date :mmddyy10.;
    index_low = intnx('month', index_date, -6);
    index_high = intnx('month', index_date, 6);
datalines;
1 3/4/2009
2 8/16/2010
3 6/6/2011
4 7/4/2009
;


data patients;
    format treatment_date date9.;
    input patient treatment_date :mmddyy10.;
datalines;
1 9/30/2008
1 10/11/2008
1 4/1/2009
2 1/1/2010
2 9/30/2010
3 12/30/2009
3 5/1/2010
3 8/1/2011
3 10/13/2011
3 12/13/2011
4 6/8/2009
4 3/1/2010
;

proc sql;
    CREATE TABLE allData AS
    SELECT a.*,
           (a.treatment_date &amp;lt; b.index_low) AS low_flag,
           (a.treatment_date BETWEEN b.index_low AND b.index_high) AS mid_flag,
           (a.treatment_date &amp;gt; b.index_high) AS high_flag,
           CASE CALCULATED low_flag WHEN 1 THEN treatment_date ELSE . END AS low_date format date9.,
           CASE CALCULATED mid_flag WHEN 1 THEN treatment_date ELSE . END AS mid_date format date9.,
           CASE CALCULATED high_flag WHEN 1 THEN treatment_date ELSE . END AS high_date format date9.
    FROM patients AS a
    LEFT JOIN indexes AS b
    ON a.patient = b.patient;
quit;

proc summary data = allData nway;
    class patient;
    var low_flag mid_flag high_flag;
    output out = want_flags max = ;
run;


proc summary data = allData nway;
    class patient;
    var low_date mid_date high_date;
    output out = want_dates min(low_date mid_date)= max(high_date) = ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 19:47:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348850#M10365</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-10T19:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348864#M10366</link>
      <description>&lt;P&gt;This is Amazing!&amp;nbsp; Thank you so much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One more last question, if I want to use calendar month instead of absolute 30/31 days interval, how should I modify the intnx function?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make the question more clear, here is the case I am struglling with. If a patient's index date is 9/15/2009, and the treatment date is 3/10/2009. Although the treatment happened a little bit more than 6 month before the index date, 3/10/2009-9/15/2009=-6.2(month). But I still want it to be within pre 6 month and post 6 month (the second flag, not the first flag). In other words, all treatments happended between 3/1/2009-3/31/2009 should be flagged as -6~+6 month. While if another treatment happened on 2/28/2009, it should be assigned to -7 month, although the actual interval is only -6.5...Do you understand what I mean?&amp;nbsp; Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 20:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348864#M10366</guid>
      <dc:creator>Tiny_Kane</dc:creator>
      <dc:date>2017-04-10T20:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to add condition at select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348881#M10367</link>
      <description>&lt;P&gt;You need to define precisely what rules need to apply for the time periods and then fine tune how you use the intnx function to determine the low and high dates.&amp;nbsp;If you'd rather&amp;nbsp;make it be 180 days +/-, then change the first argument to 'day'&amp;nbsp; and the third to +/- 180. There are probably a number of different date intervals and options ('B' or 'E', for example) to get what you want, but start with a clear and non-arbitrary rule for how you want to set the date ranges. I did read your examples, but I'm knocking this out with a few spare minutes I have and I wasn't able to easily interpret it into a clear rule. If you can do that, I or someone else here can surely help you get what you want.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 20:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-add-condition-at-select-statement-in-proc-sql/m-p/348881#M10367</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-10T20:38:02Z</dc:date>
    </item>
  </channel>
</rss>

