<?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 Names in Date field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87000#M18573</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; I have a dataset which has 1 million records. There is a date filed which as values in format 20130917. But there seem to be alphabets(names) in date field. How to get 10 records above from the point the alphabets have been included in the date field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Sep 2013 19:27:14 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2013-09-18T19:27:14Z</dc:date>
    <item>
      <title>Names in Date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87000#M18573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; I have a dataset which has 1 million records. There is a date filed which as values in format 20130917. But there seem to be alphabets(names) in date field. How to get 10 records above from the point the alphabets have been included in the date field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Sep 2013 19:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87000#M18573</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2013-09-18T19:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Names in Date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87001#M18574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you requesting the 10 records before each "date" containing non-digit characters or before the first place this occurs?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the names normally should occur after the dates in the file then likely causes involve missing or incorrect use options such as FLOWOVER or TRUNCOVER in an INFILE statement. Then the "date" is getting treated as the part of a previous line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the name occurs before the date there may be an issue with tabs in the name or possible another field and the column alignments are off.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Sep 2013 19:40:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87001#M18574</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-09-18T19:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Names in Date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87002#M18575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Treat the variable as charater variable initially, then using charater functions identify dates with alphabets, then create flag variable to get top 10 or bottom 10 of each alphabet values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2013 05:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87002#M18575</guid>
      <dc:creator>Amarnath7</dc:creator>
      <dc:date>2013-09-19T05:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Names in Date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87003#M18576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need two synchornized readings of the data, one of them 10 records behind the other (the "if _n_&amp;gt;10" below).&amp;nbsp; If the "lead' reading finds an alpha character in DATE, then set a counter to 10.&amp;nbsp; The second reading tests the counter and if it's greater than or equal to 0, it outputs the record.&amp;nbsp; It also decrements the counter.&amp;nbsp; The result should be every offending record plus the 10 records preceding each of them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is the data in a raw data file?&amp;nbsp; Let's say it's in file 'c:\temp\t.txt', and date is the first 8 characters of each record, followed by other variables of interest:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; in1 &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: Courier New;"&gt;'c:\temp\t.txt';&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; in2 &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: Courier New;"&gt;'c:\temp\t.txt'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; data want (drop=prx);&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp; retain&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; prx &lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp; infile&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; in1 &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;=end_in1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp; if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; end_in1=&lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;then do;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; date $8.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; notdigit(date) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; prx=min(_n_-&lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp; if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; _n_&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; in2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; date $8.&amp;nbsp; ... other variables .... ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; prx&amp;gt;=&lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prx=prx-1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp; end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;run&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the data is a SAS dataset (say HAVE), with DATE as a character variable, the logic is similar:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;data want (drop=prx);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; retain prx 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; if end_of_have=0 then do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have (keep=date) end=end_of_have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if notdigit(date) then prx=min(_n_-1,10);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; if _n_&amp;gt;10 then do;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prx&amp;gt;=0 then output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; prx=prx-1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 04:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87003#M18576</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2013-09-20T04:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Names in Date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87004#M18577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 20:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Names-in-Date-field/m-p/87004#M18577</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2013-09-20T20:02:56Z</dc:date>
    </item>
  </channel>
</rss>

