<?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: Use Array to Check and Use Data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177710#M302469</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I misunderstood.&lt;/P&gt;&lt;P&gt;The dates given are program entry dates. If a person enters a program section within 30 days of the previous entry it is assumed to be the same contiguous program. Otherwise it is considered a new program start.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a redo of the example about with suggested output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Oct 2014 20:19:39 GMT</pubDate>
    <dc:creator>Jeff_DOC</dc:creator>
    <dc:date>2014-10-13T20:19:39Z</dc:date>
    <item>
      <title>Use Array to Check and Use Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177704#M302463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset where I have up to 26 columns numbered col??- col??. Each column may or may not have a date (the first column, col1, always has the earliest date).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to check col2 against col1 to see if there are 30 days or less between the two dates. If there are I need col1 date, otherwise I need col2 date and continue to do the same for all subsequent columns. I need to check each column against the previous column if the difference is never 30 days or more I need the col1 value. If there is an instance of greater than 30 days I need that column's date. If there are multiple columns that meet the "over 30 days" criteria, I just need the final over 30 days column value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am thinking an array may lead me in the right direction but I'm not sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would so appreciate any help anyone could give me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please see the example file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Oct 2014 21:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177704#M302463</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2014-10-08T21:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Use Array to Check and Use Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177705#M302464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It would help to include what you expect the output to look like. I can think of several ways to assign values but the output may not be what you have in mind.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Oct 2014 22:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177705#M302464</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-10-08T22:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Use Array to Check and Use Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177706#M302465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ballardw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output I would like would simply be the record key with the col1 date (if that is the earliest qualifying date) or the record key with the last date where the &amp;lt;= 30 days was true.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Oct 2014 22:05:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177706#M302465</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2014-10-08T22:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Use Array to Check and Use Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177707#M302466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suggest post some small data and output, that would be better.&lt;/P&gt;&lt;P&gt;if you have 26 variables , that said you have 325 combination ( pick 2 out of 26&amp;nbsp;&amp;nbsp; - C 2 26). here is some dummy code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array w{*} want1-want325 ;&lt;/P&gt;&lt;P&gt;array d{*} date1-date26;&lt;/P&gt;&lt;P&gt;do i=dim(d) to 2 by -1;&lt;/P&gt;&lt;P&gt; do j=i-1 to 1 by -1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; n+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; w{n}=ifn( d{i} -d{j} &amp;lt; 30 ,d{j},d{i} )&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2014 12:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177707#M302466</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-10-09T12:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Use Array to Check and Use Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177708#M302467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ksharp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did post an Excel example of the data. I tried your code and I get a "Array subscript out of range" on the "w{n}=ifn( d{i} -d{j} &amp;lt; 30 ,d{j},d{i} )&amp;nbsp; ;" line?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm really new to arrays so I'm sure I've not used this correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Oct 2014 18:21:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177708#M302467</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2014-10-13T18:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Use Array to Check and Use Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177709#M302468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jeff: You posted an example of what your data looks like, but not the output you want based on that example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Oct 2014 19:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177709#M302468</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-10-13T19:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Use Array to Check and Use Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177710#M302469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I misunderstood.&lt;/P&gt;&lt;P&gt;The dates given are program entry dates. If a person enters a program section within 30 days of the previous entry it is assumed to be the same contiguous program. Otherwise it is considered a new program start.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a redo of the example about with suggested output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Oct 2014 20:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177710#M302469</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2014-10-13T20:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Use Array to Check and Use Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177711#M302470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I understand up through record 8, but don't understand why your example assigns Entry_Date_2 for the remaining records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that was an error, and they should have been missing, then the following might do what you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=col1-col8);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have (rename=(Entry_Date=Entry_Date_1));&lt;/P&gt;&lt;P&gt;&amp;nbsp; format Entry_Date_2 date.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array cols(*) col1-col8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _n_=1 to 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if cols(_n_)-Entry_Date_1 ge 30 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Entry_Date_2=cols(_n_);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Oct 2014 21:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-Array-to-Check-and-Use-Data/m-p/177711#M302470</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-10-13T21:32:41Z</dc:date>
    </item>
  </channel>
</rss>

