<?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: ARRAY PROBLEMS WHEN THERE ARE NO RECORDS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129435#M35280</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Array statements are not executable. They are just used to setup the data step.&amp;nbsp; So it is the same as if the ARRAY statement is outside of the IF/THEN block.&amp;nbsp; Same for other non-executable statements like KEEP/DROP/RENAME/ etc. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your example program does not make any sense.&amp;nbsp; You are assigning values to temporary variables that will just be thrown away.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you actually want to do? Perhaps there is a better way to do it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Sep 2012 19:00:04 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2012-09-24T19:00:04Z</dc:date>
    <item>
      <title>ARRAY PROBLEMS WHEN THERE ARE NO RECORDS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129434#M35279</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;I am having a problem with arrays when there are no records in the dataset&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL NOPRINT;&lt;/P&gt;&lt;P&gt;SELECT COUNT(*) INTO :CNT&lt;/P&gt;&lt;P&gt;FROM DETAILS;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA TEST;&lt;/P&gt;&lt;P&gt;SET PERSONS;&lt;/P&gt;&lt;P&gt;IF &amp;amp;CNT &amp;gt; 0 THEN DO;&lt;/P&gt;&lt;P&gt;ARRAY DTL {&amp;amp;CNT} $10. _TEMPORARY_;&lt;/P&gt;&lt;P&gt;DO i=1 to &amp;amp;CNT;&lt;/P&gt;&lt;P&gt;DTL{i}=DETAIL;&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I kept the condiiton to do it only in cases where the record count is &amp;gt; 0 but when i ran this program and there is no data it throws the error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR: Invalid dimension specification for array DTL.&amp;nbsp; The upper bound of an array dimension is smaller than its corresponding &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lower bound.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Why it is generating this error even when i kept the condition &amp;amp;CNT &amp;gt; 0 .&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 18:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129434#M35279</guid>
      <dc:creator>JasonNC</dc:creator>
      <dc:date>2012-09-24T18:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY PROBLEMS WHEN THERE ARE NO RECORDS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129435#M35280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Array statements are not executable. They are just used to setup the data step.&amp;nbsp; So it is the same as if the ARRAY statement is outside of the IF/THEN block.&amp;nbsp; Same for other non-executable statements like KEEP/DROP/RENAME/ etc. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your example program does not make any sense.&amp;nbsp; You are assigning values to temporary variables that will just be thrown away.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you actually want to do? Perhaps there is a better way to do it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 19:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129435#M35280</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-09-24T19:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY PROBLEMS WHEN THERE ARE NO RECORDS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129436#M35281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom has pointed out the erroneous assumptions your program embodies about the non-executable nature of the ARRAY statement, and even if the program ran to completion it wouldn't do anything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But assuming the program did do some real work, (say you were looking for the 2nd largest value in a collection), you could still use &amp;amp;CNT as an upper bound if you used 0 as a lower bound, as in&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ARRAY DTL {0:&amp;amp;CNT} $10. _TEMPORARY_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The array statement is still not executable, but if &amp;amp;CNT is zero, this statement would have avoided the implicit definition of an array with lower bound of 1 (the default) and upper bound of 0.&amp;nbsp; That's what provoked the "upper bound of an array is smaller than ..." message.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 19:36:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129436#M35281</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-09-24T19:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY PROBLEMS WHEN THERE ARE NO RECORDS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129437#M35282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am doing a cartesian join there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example i have a dataset like this Persons&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Persons&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Drug Tests&lt;/P&gt;&lt;P&gt;TB&lt;/P&gt;&lt;P&gt;BB&lt;/P&gt;&lt;P&gt;CF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am creating a data set like this&lt;/P&gt;&lt;P&gt;John&amp;nbsp; TB&lt;/P&gt;&lt;P&gt;John BB&lt;/P&gt;&lt;P&gt;John CF&lt;/P&gt;&lt;P&gt;JIm TB&lt;/P&gt;&lt;P&gt;Jim BB&lt;/P&gt;&lt;P&gt;JIm CF&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 19:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129437#M35282</guid>
      <dc:creator>JasonNC</dc:creator>
      <dc:date>2012-09-24T19:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY PROBLEMS WHEN THERE ARE NO RECORDS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129438#M35283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cross join in SQL instead?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select p.*, t.*&lt;/P&gt;&lt;P&gt;from persons p&lt;/P&gt;&lt;P&gt;cross join&lt;/P&gt;&lt;P&gt;tests t;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 19:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129438#M35283</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-09-24T19:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY PROBLEMS WHEN THERE ARE NO RECORDS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129439#M35284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;SQL is the easiest.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;To do it with a data step you do not need any macro variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set persons;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do i=1 to nobs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set drugtests nobs=nobs point=i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&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;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;If you want to keep the people when there are no drug tests you can add.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;if nobs=0 then output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 19:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-PROBLEMS-WHEN-THERE-ARE-NO-RECORDS/m-p/129439#M35284</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-09-24T19:57:56Z</dc:date>
    </item>
  </channel>
</rss>

