<?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: Subset dataset by date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260110#M50431</link>
    <description>&lt;P&gt;If you have a SAS date you can use the following to filter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can specify a date constant in SAS using the date9 format and with a d after the date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"05Sep2015"d&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can use the MDY function to create a SAS date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;mdy(5, 19, 15)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2016 14:24:30 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-03-30T14:24:30Z</dc:date>
    <item>
      <title>Subset dataset by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260087#M50416</link>
      <description>&lt;P&gt;hi ,&lt;/P&gt;
&lt;P&gt;this isate ganesh, i have one doubt ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id &amp;nbsp; &amp;nbsp; name &amp;nbsp; &amp;nbsp;date&lt;/P&gt;
&lt;P&gt;101 &amp;nbsp;xxx &amp;nbsp; &amp;nbsp; &amp;nbsp;19/05/15&lt;/P&gt;
&lt;P&gt;102 YYY &amp;nbsp; &amp;nbsp; &amp;nbsp;19/06/16&lt;/P&gt;
&lt;P&gt;103 zzz &amp;nbsp; &amp;nbsp; &amp;nbsp; 19/05/15&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want '19/05/15' date values &amp;nbsp;into output dataset ,how to solve this probleam .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;A.Ganesh&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 14:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260087#M50416</guid>
      <dc:creator>ganeshsas764</dc:creator>
      <dc:date>2016-03-30T14:22:40Z</dc:date>
    </item>
    <item>
      <title>subset date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260088#M50425</link>
      <description>&lt;P&gt;hi ,&lt;/P&gt;&lt;P&gt;this is ganesh, i have one doubt ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp; name &amp;nbsp; &amp;nbsp;date&lt;/P&gt;&lt;P&gt;101 &amp;nbsp;xxx &amp;nbsp; &amp;nbsp; &amp;nbsp;19/05/15&lt;/P&gt;&lt;P&gt;102 YYY &amp;nbsp; &amp;nbsp; &amp;nbsp;19/06/16&lt;/P&gt;&lt;P&gt;103 zzz &amp;nbsp; &amp;nbsp; &amp;nbsp; 19/05/15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want '19/05/15' date values only &amp;nbsp;into output dataset ,how to solve this probleam .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;A.Ganesh&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 14:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260088#M50425</guid>
      <dc:creator>ganeshsas764</dc:creator>
      <dc:date>2016-03-30T14:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: subset date date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260091#M50418</link>
      <description>&lt;P&gt;Please elaborate.&lt;/P&gt;
&lt;P&gt;Is the example data from an external file?&lt;/P&gt;
&lt;P&gt;And you wish to store it in a SAS data set (output)?&lt;/P&gt;
&lt;P&gt;Use an informat to translate the date into a SAS date numerical variable.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 14:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260091#M50418</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-03-30T14:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: subset date date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260092#M50419</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is date a numeric variable or character. &amp;nbsp;Depending on that you could use where clause or if etc.&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  where date="19/05/15";
run;

or 

data want;
  set have;
  where date=input("19/05/15",ddmmyy8.);
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Mar 2016 14:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260092#M50419</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-30T14:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: subset date date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260094#M50420</link>
      <description>that values are stored in sas dataset,how to subset particular date values&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 30 Mar 2016 14:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260094#M50420</guid>
      <dc:creator>ganeshsas764</dc:creator>
      <dc:date>2016-03-30T14:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: subset date date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260100#M50426</link>
      <description>tq&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 30 Mar 2016 14:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260100#M50426</guid>
      <dc:creator>ganeshsas764</dc:creator>
      <dc:date>2016-03-30T14:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Subset dataset by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260110#M50431</link>
      <description>&lt;P&gt;If you have a SAS date you can use the following to filter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can specify a date constant in SAS using the date9 format and with a d after the date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"05Sep2015"d&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can use the MDY function to create a SAS date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;mdy(5, 19, 15)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2016 14:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/260110#M50431</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-30T14:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Subset dataset by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/731681#M227927</link>
      <description>&lt;P&gt;Use quotations followed by d (if using only date - dt, if you're using datetime), and write the date case as "19May15"d (it won't work with "19/05/15"d):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* ===================================== */
/* Date */

DATA subset_by_date;
	INPUT id name $ date;
	INFORMAT date ddmmyy8.;
	FORMAT date ddmmyy8.;
	DATALINES;
101 xxx 19/05/15
102 YYY 19/06/16
103 zzz 19/05/15
;
RUN;

DATA works;
	SET subset_by_date;
	WHERE date = '19May15'd;
RUN;
* Returns only ids 101 and 103;

DATA works_too;
	SET subset_by_date;
	WHERE '18MAY15'D &amp;lt; date &amp;lt; '20May15'd;
RUN;
* Returns only ids 101 and 103;

DATA wont_work;
	SET subset_by_date;
	WHERE date = '19/05/15'd;
RUN;
* ERROR: Invalid date/time/datetime constant '19/05/15'd. ;

/* ===================================== */
/* Datetime */

DATA subset_by_datetime;
	INPUT id name $ datetime;
	INFORMAT datetime anydtdtm40.;
	FORMAT datetime datetime.;
	DATALINES;
101 xxx 19/05/15
102 YYY 19/06/16
103 zzz 19/05/15
;
RUN;

DATA works_datetime;
	SET subset_by_datetime;
	WHERE datetime = '16Jun19:00:00:00'dt;
RUN;
* Returns only id 102 ;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Apr 2021 19:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/731681#M227927</guid>
      <dc:creator>ogustavo</dc:creator>
      <dc:date>2021-04-06T19:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: subset date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/731700#M227940</link>
      <description>&lt;P&gt;When you said you want&amp;nbsp; '&lt;SPAN&gt;19/05/15' date values only &amp;nbsp;into output dataset, do you mean make all other dates become&amp;nbsp;'19/05/15', or you want to delete other dates but&amp;nbsp;'19/05/15'?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 20:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/731700#M227940</guid>
      <dc:creator>SAS-questioner</dc:creator>
      <dc:date>2021-04-06T20:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Subset dataset by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/731724#M227950</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376504"&gt;@SAS-questioner&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/309644"&gt;@ogustavo&lt;/a&gt;&amp;nbsp;This is a 5 year old thread, if you have a question it may be best to post it as a new post not on top of this one. Only users who initially responded to this post will see any updates/responses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 21:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/731724#M227950</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-06T21:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Subset dataset by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/731734#M227959</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; What I posted is a possible solution to the OP's issue, is it not? Where is the proper place for that?</description>
      <pubDate>Tue, 06 Apr 2021 22:28:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/731734#M227959</guid>
      <dc:creator>ogustavo</dc:creator>
      <dc:date>2021-04-06T22:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Subset dataset by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/731788#M227984</link>
      <description>I'm not sure of the value of answering a 5+ year old question but that is your prerogative.</description>
      <pubDate>Wed, 07 Apr 2021 02:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subset-dataset-by-date/m-p/731788#M227984</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-07T02:37:57Z</dc:date>
    </item>
  </channel>
</rss>

