<?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: Creating a subsample based on after date condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728621#M226712</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/246836"&gt;@qoit&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your solution, I am of curiosity, For example I want to get the monthly data after this day&lt;/P&gt;
&lt;P&gt;I replicate your code but it does not work, could you please help me to sort it out?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA SAMPLE3;
	SET romania (where=(datadate &amp;gt; "01JUL2005"m )); /*I changed from d to m here*/
run;

proc means data=SAMPLE3;
class curcdd;
var exchg;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;35         	SET romania (where=(datadate &amp;gt; "01JUL2005"m ));
                                           ____________
                                           49         22
                                                      76
ERROR: Syntax error while parsing WHERE clause.

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, GE, GT, LE, LT, 
              NE, OR, ^=, |, ||, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Mar 2021 02:45:57 GMT</pubDate>
    <dc:creator>Phil_NZ</dc:creator>
    <dc:date>2021-03-24T02:45:57Z</dc:date>
    <item>
      <title>Creating a subsample based on after date condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728619#M226710</link>
      <description>&lt;P&gt;Hi all SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset &lt;STRONG&gt;romania&lt;/STRONG&gt; as below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;GVKEY	IID	DATADATE
212834	01W	03JAN2002
212834	01W	04JAN2002
212834	01W	07JAN2002
212834	01W	08JAN2002
212834	01W	09JAN2002
212834	01W	14JAN2002
212834	01W	15JAN2002&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I want is I want to get the observation after 08JAN2002, so, my desired output is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;GVKEY    IID   DATADATE
212834	01W	   09JAN2002
212834	01W	   14JAN2002
212834	01W	   15JAN2002&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I tried to code but it does not work properly&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA SAMPLE3;
	SET romania (where=(datadate &amp;gt; 08JAN2002 ));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;35         	SET romania (where=(datadate &amp;gt; 08JAN2002 ));
                                             _______
                                             22
                                             76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, GE, GT, LE, LT, 
              NE, OR, ^=, |, ||, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Could you please help me to sort it out?&lt;/P&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 02:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728619#M226710</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-24T02:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a subsample based on after date condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728620#M226711</link>
      <description>SET romania (where=(datadate &amp;gt; "08JAN2002"d )); &lt;BR /&gt;&lt;BR /&gt;will work.</description>
      <pubDate>Wed, 24 Mar 2021 02:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728620#M226711</guid>
      <dc:creator>qoit</dc:creator>
      <dc:date>2021-03-24T02:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a subsample based on after date condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728621#M226712</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/246836"&gt;@qoit&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your solution, I am of curiosity, For example I want to get the monthly data after this day&lt;/P&gt;
&lt;P&gt;I replicate your code but it does not work, could you please help me to sort it out?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA SAMPLE3;
	SET romania (where=(datadate &amp;gt; "01JUL2005"m )); /*I changed from d to m here*/
run;

proc means data=SAMPLE3;
class curcdd;
var exchg;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;35         	SET romania (where=(datadate &amp;gt; "01JUL2005"m ));
                                           ____________
                                           49         22
                                                      76
ERROR: Syntax error while parsing WHERE clause.

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, GE, GT, LE, LT, 
              NE, OR, ^=, |, ||, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 02:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728621#M226712</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-24T02:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a subsample based on after date condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728624#M226713</link>
      <description>Yes, it wouldn't work. You need to affix a D (not any other alphabet). D is a date constant which tells SAS to convert the value to a SAS date at the compile time.</description>
      <pubDate>Wed, 24 Mar 2021 02:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728624#M226713</guid>
      <dc:creator>qoit</dc:creator>
      <dc:date>2021-03-24T02:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a subsample based on after date condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728804#M226762</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212695"&gt;@Phil_NZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/246836"&gt;@qoit&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your solution, I am of curiosity, For example I want to get the monthly data after this day&lt;/P&gt;
&lt;P&gt;I replicate your code but it does not work, could you please help me to sort it out?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA SAMPLE3;
	SET romania (where=(datadate &amp;gt; "01JUL2005"m )); /*I changed from d to m here*/
run;

proc means data=SAMPLE3;
class curcdd;
var exchg;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;35         	SET romania (where=(datadate &amp;gt; "01JUL2005"m ));
                                           ____________
                                           49         22
                                                      76
ERROR: Syntax error while parsing WHERE clause.

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, GE, GT, LE, LT, 
              NE, OR, ^=, |, ||, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I am not sure what you mean by "get the monthly data after this day" but one interpretation for the attempted code could be "create a summary for each calendar month" which can be done by including the date variable as a class variable and using a format with the date variable that creates "month" intervals. Note, there is no actual need for a separate data set as you can use a Where a statement in proc mean (or summary or almost any procedure).&lt;/P&gt;
&lt;PRE&gt;proc means data=romania;
   where datadate &amp;gt; "01JUL2005"d;
   class curcdd datadate;
   format datadate mmyys7.; /* mm/yyyy appearance 07/2005*/
   /* or mmyyp7  07.2005, mmyyd7. 07-2005 mmyyc7. 07:2005
     yymmc7. 2005:07 (and other versions of yymmx
     yymm7. 2005M07  monyy7. JUL2005 
   */
   var exchg;
run;&lt;/PRE&gt;
&lt;P&gt;Groups created by applying a format to variable like this will be honored by almost all the report, analysis and graphing procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For dates, times and datetime values you can create a lot of custom formats as well using Proc Format.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 16:10:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728804#M226762</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-24T16:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a subsample based on after date condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728882#M226808</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An amazing suggestion and explanation for me, which really benefits me in the future because I am keen on something that I can play with like that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warmest rergards.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 20:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subsample-based-on-after-date-condition/m-p/728882#M226808</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-24T20:42:22Z</dc:date>
    </item>
  </channel>
</rss>

