<?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 and Do Loop &amp;quot;Skipping&amp;quot; - skips first observation line in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149236#M29461</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nevermind everyone, I figured it out. Apparently if you put your set statement at the end as opposed to right below the data step you get this problem I've described. If anyone can explain why that is I'd be grateful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Jan 2014 15:46:30 GMT</pubDate>
    <dc:creator>rrevans</dc:creator>
    <dc:date>2014-01-22T15:46:30Z</dc:date>
    <item>
      <title>Array and Do Loop "Skipping" - skips first observation line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149234#M29459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rationale: searching through patient records for specific ICD-9 codes (char) using prxmatch() and flagging for disease condition. Data looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;id&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;icd9_1&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;icd9_2&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;icd9_3&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;153.4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;285.1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;427.31&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;578.1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;584.5&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;570&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each observation has a different number of variables (icd9_{i}) the max is icd9_39. What I want is the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;id&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;icd9_1...&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;...icd9_39&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Cancer&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;AIDS&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;153.4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;578.1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;276.2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Code:&lt;/P&gt;&lt;P&gt;data want&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array icd9_{39} $ icd9_1-icd9_39;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cancer = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to 39;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prxmatch("/140/", icd9_{i}) or prxmatch("/141/", icd9_{i}) or ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then cancer = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aids = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to 39;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prxmatch("/042/", icd9_{i}) or prxmatch("/043/", icd9_{i}) or ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then aids = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works perfectly for me except that it skips the first observation and puts the the icd9 codes from the first observation into the second observations disease variables then the 2nd into the 3rd and the 3rd into the 4th and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question is: How do I fix this? I tried messing with my "i" value and haven't found a solution. I'll keep tinkering.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2014 15:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149234#M29459</guid>
      <dc:creator>rrevans</dc:creator>
      <dc:date>2014-01-22T15:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Array and Do Loop "Skipping" - skips first observation line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149235#M29460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried moving your set statement to the top, right after the data statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2014 15:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149235#M29460</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-01-22T15:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Array and Do Loop "Skipping" - skips first observation line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149236#M29461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nevermind everyone, I figured it out. Apparently if you put your set statement at the end as opposed to right below the data step you get this problem I've described. If anyone can explain why that is I'd be grateful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2014 15:46:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149236#M29461</guid>
      <dc:creator>rrevans</dc:creator>
      <dc:date>2014-01-22T15:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Array and Do Loop "Skipping" - skips first observation line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149237#M29462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll have to switch gears related to how you think about the SET statement.&amp;nbsp; It is not just a label that tells&amp;nbsp; you where the data comes from.&amp;nbsp; It is an executable statement.&amp;nbsp; During the course of a DATA step, it executes many times and each time it reads in the next observation from the incoming SAS data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In that light, consider what happens on your first observation (in your original, uncorrected DATA step).&amp;nbsp; You calculate AIDS and CANCER, then read in the first observation from the incoming data, and finally output the result.&amp;nbsp; So the calculated values will be 0.&amp;nbsp; Then the DATA step continues.&amp;nbsp; It calculates AIDS and CANCER based on the current data values (which came from the first observation, and are retained in memory).&amp;nbsp; Then it reads in the second observation, and outputs the final result.&amp;nbsp; So AIDS and CANCER are, as you observed, based on the first observation but the final data values come from the second observation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a medium-complex process, and there are a host of related topics.&amp;nbsp; For example, you could scour the documentation to study the difference between the compilation phase vs. the execution phase of the DATA step.&amp;nbsp; But the description above is probably the most relevant to understanding the results you saw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2014 17:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149237#M29462</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-01-22T17:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Array and Do Loop "Skipping" - skips first observation line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149238#M29463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You for Answering. I forget these details at times. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jan 2014 18:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-and-Do-Loop-quot-Skipping-quot-skips-first-observation/m-p/149238#M29463</guid>
      <dc:creator>rrevans</dc:creator>
      <dc:date>2014-01-22T18:49:41Z</dc:date>
    </item>
  </channel>
</rss>

