<?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 subsets of dataset based on year in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-subsets-of-dataset-based-on-year/m-p/714619#M80079</link>
    <description>&lt;P&gt;Before going to too far. How do you want to use the subset?&lt;/P&gt;
&lt;P&gt;What is the Current format assigned to your date variable?&lt;/P&gt;
&lt;P&gt;Run&lt;/P&gt;
&lt;P&gt;Proc Contents data=yourdatasetname;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;if you don't know how to check the existing format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You Picture makes me suspect that you may have character values for your date which means additional work.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jan 2021 15:43:17 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-01-27T15:43:17Z</dc:date>
    <item>
      <title>Creating subsets of dataset based on year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-subsets-of-dataset-based-on-year/m-p/714468#M80072</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a subset of an entire dataset based on year.&amp;nbsp; I've read that i need to specify the date format date9. first in order to do so. However, i'm not so certain. I appreciate the help as to the code i should use. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 07:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-subsets-of-dataset-based-on-year/m-p/714468#M80072</guid>
      <dc:creator>igsteo</dc:creator>
      <dc:date>2021-01-28T07:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating subsets of dataset based on year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-subsets-of-dataset-based-on-year/m-p/714471#M80073</link>
      <description>&lt;P&gt;You do NOT need to reformat a date variable to select a subset based on year.&amp;nbsp; The format does not change the underlying value, and it is the value that you have to filter.&amp;nbsp; Compare the date variable in your datasets to two date constants, namely jan 1 of the year you want and dec 31 of the year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;YOu can specify a date constant in sas using the syntax of a date literal&amp;nbsp; (i.e.&amp;nbsp; &amp;nbsp;'ddMONyyyy'd):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    where '01jan2017'd &amp;lt;= date &amp;lt;= '31dec2017'd;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You may get suggestions to use a year function, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    where year(date) = 2017;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;True, it's simpler syntax, but involves more work, because it forces SAS to convert a numeric value prior to the comparison, unlike the date literal approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some examples of the syntax for the most common other types of SAS literals:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
      x=1;   /*Numeric literal */
      y='A'; /*Character literal*/
      tim='13:30:21.123't;    /*Time literal, but don't forget to format it to be readable*/
      dattime='18jan2003:9:27:05.123'dt;  /*Don't forget to format for readability*/
      put x=  y=   tim=time12.3   dattime=datetime22.3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 03:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-subsets-of-dataset-based-on-year/m-p/714471#M80073</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-01-27T03:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating subsets of dataset based on year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-subsets-of-dataset-based-on-year/m-p/714619#M80079</link>
      <description>&lt;P&gt;Before going to too far. How do you want to use the subset?&lt;/P&gt;
&lt;P&gt;What is the Current format assigned to your date variable?&lt;/P&gt;
&lt;P&gt;Run&lt;/P&gt;
&lt;P&gt;Proc Contents data=yourdatasetname;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;if you don't know how to check the existing format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You Picture makes me suspect that you may have character values for your date which means additional work.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 15:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-subsets-of-dataset-based-on-year/m-p/714619#M80079</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-27T15:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating subsets of dataset based on year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-subsets-of-dataset-based-on-year/m-p/714636#M80081</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/361282"&gt;@igsteo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to create a subset of an entire dataset based on year.&amp;nbsp; I've read that i need to specify the date format date9. first in order to do so. However, i'm not so certain. I appreciate the help as to the code i should use. Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The whole idea of subsetting a data set by year should be avoided (except in rare cases). You can do almost any analysis you want without doing this subsetting. You can use a BY statement, and then obtain analyses for each year. To do this, you will need a variable in a data set that contains the YEAR. You can also use WHERE statements to limit the analysis to specific year.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 16:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-subsets-of-dataset-based-on-year/m-p/714636#M80081</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-27T16:14:27Z</dc:date>
    </item>
  </channel>
</rss>

