<?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: PRXPARSE and negative integers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860552#M339953</link>
    <description>Thank you for sharing your ideas!</description>
    <pubDate>Thu, 23 Feb 2023 19:55:05 GMT</pubDate>
    <dc:creator>Yoko</dc:creator>
    <dc:date>2023-02-23T19:55:05Z</dc:date>
    <item>
      <title>PRXPARSE and negative integers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860476#M339917</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a code somebody wrote:&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dob = PRXPARSE ("/\d{5} |&amp;nbsp;\d{4} |&amp;nbsp;\d{3} |&amp;nbsp;\d{2} |&amp;nbsp;\d{1} /");&lt;/P&gt;&lt;P&gt;I understand that SAS date is expressed anywhere from 1 to 5 digits.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I need to add a negative sign for those who were born before 1960.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody know how to add it to the code above?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yoko&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 15:37:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860476#M339917</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2023-02-23T15:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: PRXPARSE and negative integers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860489#M339926</link>
      <description>&lt;P&gt;If you have a SAS date value then perhaps you should tell us what you are looking for. Searching strings, which is what the PRX functions are for is likely going to be a headache.&lt;/P&gt;
&lt;P&gt;If you have a variable that supposedly contains a date of birth and you are looking for those born before 1960 then use the year function.&lt;/P&gt;
&lt;PRE&gt;if year(dateofbirthvariable) &amp;lt; 1960 then /* do what ever is needed*/&lt;/PRE&gt;
&lt;P&gt;There a many functions for working with date, time and datetime values and I am fairly certain they are going to much easier than trying to parse strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 16:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860489#M339926</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-23T16:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: PRXPARSE and negative integers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860503#M339932</link>
      <description>Hello,&lt;BR /&gt;This is a part of a large program which identifies valid, invalid, or missing field values for multiple variables. This part is for date of birth (DOB). I found that the program categorises DOB before 1960 as 'INVALID' with %let dob = PRXPARSE ("/\d{5} | \d{4} | \d{3} | \d{2} | \d{1} /"); I suspect that this is because the code categorises any 1-5 positive digits as valid, but categorises negative digits invalid. So, I'm looking for a solution for DOB as SAS date.&lt;BR /&gt;Thank you,&lt;BR /&gt;Yoko&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Feb 2023 17:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860503#M339932</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2023-02-23T17:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: PRXPARSE and negative integers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860507#M339936</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152732"&gt;@Yoko&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello,&lt;BR /&gt;This is a part of a large program which identifies valid, invalid, or missing field values for multiple variables. This part is for date of birth (DOB). I found that the program categorises DOB before 1960 as 'INVALID' with %let dob = PRXPARSE ("/\d{5} | \d{4} | \d{3} | \d{2} | \d{1} /"); I suspect that this is because the code categorises any 1-5 positive digits as valid, but categorises negative digits invalid. So, I'm looking for a solution for DOB as SAS date.&lt;BR /&gt;Thank you,&lt;BR /&gt;Yoko&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to define what an "invalid" date might look like. If the variable is a SAS date value then it can be from the year 1582 to 20,000 (yes a 5-digit year ).&lt;/P&gt;
&lt;P&gt;Generally I validate date values when the values are read into SAS as text. The informats that read common date structures will take care of validating whether the string is a valid date and catches the stuff like incorrect leap days and invalid days like November 31, which that code looking at digits would not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might look for specific dates, such as 1/1/1900 (a common value for people to use with Microsoft products) or year of 9999 as somewhat common codes from different places.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a reason to believe that your dates should be in a specific range then something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'01JAN1925'd le DOB le today()&lt;/P&gt;
&lt;P&gt;checks for a date of birth between 1 January 1925 and today. Note that your current check will not catch dates of birth in the future. A "valid" number, according to that PRX, of 99999 would correspond to 15 Oct 2233, hardly a likely valid DOB value. In fact, running that code on 23 Feb 2023 any number greater than 23064 would be very suspect for an actual date of birth.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 17:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860507#M339936</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-23T17:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: PRXPARSE and negative integers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860552#M339953</link>
      <description>Thank you for sharing your ideas!</description>
      <pubDate>Thu, 23 Feb 2023 19:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXPARSE-and-negative-integers/m-p/860552#M339953</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2023-02-23T19:55:05Z</dc:date>
    </item>
  </channel>
</rss>

