<?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: can't filter missing dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973199#M377661</link>
    <description>&lt;P&gt;It's often helpful to run PROC FREQ to check the values of your variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;prof freq data=work.tsa_nodupkey;
  tables Incident_Date*Date_Received/missing list;
  format Incident_Date Date_Received year.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;are the results informative?&lt;/P&gt;</description>
    <pubDate>Mon, 25 Aug 2025 12:24:00 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2025-08-25T12:24:00Z</dc:date>
    <item>
      <title>can't filter missing dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973172#M377655</link>
      <description>&lt;P&gt;Hi, I am trying to follow the instructions in the SAS beginner programming course on the TSA Claims Data. I am filtering through the data as they proposed, but whenever I try to condition on the dates being missing or '.' to make them be 'needs review', it replaces all of the 220k rows with it, instead of just the missing ones:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what they have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rajueric_3-1755990262780.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109215i955ABCF27ACD8FF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rajueric_3-1755990262780.png" alt="rajueric_3-1755990262780.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rajueric_2-1755990230404.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109214iD335D32E083B6F56/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rajueric_2-1755990230404.png" alt="rajueric_2-1755990230404.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.tsa_report;
	set work.tsa_nodupkey;
    retain Date_Issues;
/* 3. Clean the Claim_Site column. */
    if Claim_Site in('-' '') then Claim_Site='Unknown';
/* 4. Clean the Disposition column. */
    if Disposition in('-' '') then Disposition='Unknown';
        else if Disposition in('Closed: Contractor Claim' 'losed: Contractor Claim') then
            Disposition='Closed:Contractor Claim';
    	else if Disposition='Closed: Canceled' then Disposition='Closed:Canceled';
/* 5. Clean the Claim_Type column. */
    if Claim_Type in('-' '')  then Claim_Type='Unknown';
    	else if Claim_Type in('Passenger Property Loss/Personal Injur'
    	'Passenger Property Loss/Personal Injury') then
            Claim_Type='Passenger Property Loss';
        else if Claim_Type='Property Damage/Personal Injury' then
        	Claim_Type='Passenger Damage';
/* 6. Convert all State values to uppercase and all StateName values to proper case. */
    StateName=propcase(StateName);
    State=upcase(State);
/* 7. Create a new column to indicate date issues. */
    if (Incident_Date &amp;gt; Date_Received or
        Date_Received = . or
        Incident_Date = . or
        year(Incident_Date) &amp;lt; 2002 or
        year(Incident_Date) &amp;gt; 2017 or
        year(Date_Received) &amp;lt; 2002 or
        year(Date_Received) &amp;gt; 2017) then Date_Issues='Needs Review';
/* 8. Add permanent labels and formats. */
    format Date_Received Incident_Date date9. Close_Amount dollar20.2;
    label Claim_Number='Claim Number'
    	Incident_Date='Incident Date'
    	Date_Received='Date Received'
    	Airport_Code='Airport Code'
    	Airport_Name='Airport Name'
    	Claim_Type='Claim Type'
    	Claim_Site='Claim Site'
    	Item_Category='Item Category'
    	Close_Amount='Close Amount'
    	Date_Issues='Date Issues';
/* 9. Drop County and City. */
	drop County City;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rajueric_1-1755990196029.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109213iD610A220A551FAA1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rajueric_1-1755990196029.png" alt="rajueric_1-1755990196029.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know why it's doing this as I had this problem before.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Aug 2025 23:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973172#M377655</guid>
      <dc:creator>rajueric</dc:creator>
      <dc:date>2025-08-23T23:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: can't filter missing dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973173#M377656</link>
      <description>&lt;P&gt;How are the variables defined?&amp;nbsp; Make sure those are the actual variable names. Make sure they are actually numeric variables that contain date values. Not character variables.&amp;nbsp; Not datetime values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try looking at the current values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=tsa_nodupkey ;
  tables Date_Received*Incident_Date / list;
  format Date_Received Incident_Date year4.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Make sure you actually have some cases that fall into the years 2002 to 2017.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if the variables contain DATETIME values then the YEAR() function will return a missing value, which in comparison operations will be considered smaller than any actual number.&lt;/P&gt;
&lt;PRE&gt;1    data _null_;
2      x=datetime();
3      if year(x) &amp;lt; 2017 then put 'Less than 2017 ' x= datetime19. x=dtdate9. x=dtyear4.;
4    run;

NOTE: Invalid argument to function YEAR(2071614560.5) at line 3 column 6.
Less than 2017 x=24AUG2025:00:29:21 x=24AUG2025 x=2025
x=2071614560.5 _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
      missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 at 3:6
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;Try recoding the IF condition to be simpler.&amp;nbsp; You seem to want this condition.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not (Incident_Date &amp;lt;= Date_Received 
   and year(Incident_Date) in (2002:2017)
   and year(Date_Received) in (2002:2017)
   ) then Date_Issues='Needs Review';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Aug 2025 04:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973173#M377656</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-08-24T04:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: can't filter missing dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973175#M377657</link>
      <description>What does the log tell you (Maxim 2)?</description>
      <pubDate>Sun, 24 Aug 2025 08:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973175#M377657</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-08-24T08:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: can't filter missing dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973199#M377661</link>
      <description>&lt;P&gt;It's often helpful to run PROC FREQ to check the values of your variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;prof freq data=work.tsa_nodupkey;
  tables Incident_Date*Date_Received/missing list;
  format Incident_Date Date_Received year.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;are the results informative?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2025 12:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973199#M377661</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-08-25T12:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: can't filter missing dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973473#M377697</link>
      <description>&lt;P&gt;thank you! it turns out I had accidentally added a 'retain' command which preserved values for every row&lt;/P&gt;</description>
      <pubDate>Thu, 28 Aug 2025 01:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/can-t-filter-missing-dates/m-p/973473#M377697</guid>
      <dc:creator>rajueric</dc:creator>
      <dc:date>2025-08-28T01:23:04Z</dc:date>
    </item>
  </channel>
</rss>

