<?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: Exclude people by date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792414#M253881</link>
    <description>&lt;P&gt;Create the dates with the MDY function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if enty &amp;gt; mdy(1,1,year) or (exit ne . and exit &amp;lt; mdy(12,31,year)) then output exclude;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Jan 2022 10:50:45 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-01-26T10:50:45Z</dc:date>
    <item>
      <title>Exclude people by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792209#M253820</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ich have following problem. I work with patient data and I have following variables: the year of observation (year), the entry date (entry, format yymmdd10.) and the exit date (exit, format yymmdd10.) into the insurance. There is a "." when there is no exit date. I only want to work with patients who were insured the whole year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore I would like to identify the patients that are not and put them in a separate file. For example observation year is 2014, but the entry date is after 2014-01-01. I tried following command:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data exclude; set all;&lt;BR /&gt;if year=2014 and (enty&amp;gt;2014-01-01 or (exit&amp;lt;2014-12-31 and exit ne .) then output exclude;&lt;BR /&gt;if year=2015 and (enty&amp;gt;2015-01-01 or (exit&amp;lt;2015-12-31 and exit ne .) then output exclude;&lt;BR /&gt;...and so on, for all available years&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does not work, I have the same amount of patients in my new file (exclude).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to do it step by step by first "excluding" the patients with entry date after 20xx-01-01, then "excluding" patients with exid date before 20xx-12-31. Still the same amount of patients.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe there is a problem with the format of the date and the command has to be written different? Or what else could be the problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very happy for solutions. Thank you in advance,&lt;/P&gt;&lt;P&gt;Tamino&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 15:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792209#M253820</guid>
      <dc:creator>Tamino</dc:creator>
      <dc:date>2022-01-25T15:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude people by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792214#M253822</link>
      <description>&lt;P&gt;Show us the LOG of your code. I suspect some warnings about value conversions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your dates are actual SAS dates then you do not compare them to things like "2014-01-01". If the values are dates you compare to a standard value of "01JAN2014"d. There are so many ways of arranging numerals in nearly random ways that SAS only supports use of dates in Date9 (or similar) , in quotes with a following D to tell the compiler to treat the value as date. You may have to show us the results of PROC Contents to confirm the type of your variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: "Does not work" is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the "&amp;lt;/&amp;gt;" to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "&amp;lt;/&amp;gt;" icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 16:07:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792214#M253822</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-25T16:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude people by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792409#M253877</link>
      <description>&lt;P&gt;Thank you for your answer and sorry about the vague expression.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are no warnings in the LOG, it just tells me that the new file has the same amount of patients as the source file (see attachement).&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Note: BPMEDI.EXCL = exclude file, BPMEDI.BEST = all file&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think it is a problem with the format of the dates. The date is printed as "2014-01-01" but the variable is numeric as days counted up from 1960-01-01. So could the solution be to use the number of days in the command&lt;SPAN&gt;&amp;nbsp;instead of the date?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 10:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792409#M253877</guid>
      <dc:creator>Tamino</dc:creator>
      <dc:date>2022-01-26T10:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude people by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792414#M253881</link>
      <description>&lt;P&gt;Create the dates with the MDY function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if enty &amp;gt; mdy(1,1,year) or (exit ne . and exit &amp;lt; mdy(12,31,year)) then output exclude;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jan 2022 10:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792414#M253881</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-26T10:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude people by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792415#M253882</link>
      <description>&lt;P&gt;PS date literals must be supplied to the SAS interpreter in the form&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'ddmonyyyy'd&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where mon is the English three-letter abbreviation of the month, so 2022-01-01 is written as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'01JAN2022"d&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The month can also be written in lowercase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in your code, the dates need to be dynamic, so no literals are necessary.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 10:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792415#M253882</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-26T10:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude people by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792416#M253883</link>
      <description>&lt;P&gt;PPS 2014-01-01 is recognized by the SAS interpreter as a numeric formula, so you get the number 2014 minus 1 minus 1 = 2012, which is a day in the 1960s (&lt;SPAN&gt;1965-07-05)&lt;/SPAN&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 10:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792416#M253883</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-26T10:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude people by date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792424#M253889</link>
      <description>Thank you very much!&lt;BR /&gt;&lt;BR /&gt;With this command I got the file with the patients I wanted in it.</description>
      <pubDate>Wed, 26 Jan 2022 11:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exclude-people-by-date/m-p/792424#M253889</guid>
      <dc:creator>Tamino</dc:creator>
      <dc:date>2022-01-26T11:48:00Z</dc:date>
    </item>
  </channel>
</rss>

