<?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: Collapsing Observations using Arrays in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100422#M28241</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Array &lt;STRONG&gt;visit&lt;/STRONG&gt; has 4 elements. You access an element of array&lt;STRONG&gt; visit&lt;/STRONG&gt; with the bracket notation :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;x = visit[2];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;visit[3] = y;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the first statement assigns the second element of array&lt;STRONG&gt; visit&lt;/STRONG&gt; to &lt;STRONG&gt;x&lt;/STRONG&gt;. the second statement assigns &lt;STRONG&gt;y&lt;/STRONG&gt; to the third element of array&lt;STRONG&gt; visit&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The statement &lt;STRONG&gt;call missing (of visit&lt;/STRONG&gt;&lt;LI&gt;&lt;STRONG&gt;, counter)&lt;/STRONG&gt; assigns missing values to all the elements of array&lt;STRONG&gt; visit&lt;/STRONG&gt; (the star notation means all elements) and to variable &lt;STRONG&gt;counter&lt;/STRONG&gt;. It just so happens that this is the first time variable &lt;STRONG&gt;counter&lt;/STRONG&gt; is mentioned.&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 08 Apr 2013 00:57:19 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2013-04-08T00:57:19Z</dc:date>
    <item>
      <title>Collapsing Observations using Arrays</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100421#M28240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The following is the code for converting multiple rows of info into single observation using ARRAYS..&lt;/P&gt;&lt;P&gt;Could someone explain to me the highlighted portions....&lt;/P&gt;&lt;P&gt;on page 15-16 of the following paper&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/97529_Using_Arrays_in_SAS_Programming.pdf" title="http://support.sas.com/resources/papers/97529_Using_Arrays_in_SAS_Programming.pdf"&gt;http://support.sas.com/resources/papers/97529_Using_Arrays_in_SAS_Programming.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=expand; &lt;/P&gt;&lt;P&gt;by patient_ID date_of_visit; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;data collapse; &lt;/P&gt;&lt;P&gt;set expand; &lt;/P&gt;&lt;P&gt;by patient_ID; &lt;/P&gt;&lt;P&gt;/* Define an array for the new visit variables. */ &lt;/P&gt;&lt;P&gt;array visit[4]; &lt;/P&gt;&lt;P&gt;/* Retain the variables that are associated with the array. */ &lt;/P&gt;&lt;P&gt;retain visit;&lt;/P&gt;&lt;P&gt;/* Clear the visit variables and the counter for each new BY */ &lt;/P&gt;&lt;P&gt;/* group (Patient_ID). */ &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if first.patient_ID then call missing(of visit&lt;/STRONG&gt;&lt;LI&gt;&lt;STRONG&gt;, counter);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*where is this "counter" variable coming from?there was no mention earlier. and what does call missing(of visit&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;,counter mean&lt;/STRONG&gt;&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;/* Increment the counter that is used to reference the element */ &lt;/P&gt;&lt;P&gt;/* of array to assign date. */ &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;counter + 1;&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;&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;/* Assign the date to the proper element of the array. */ &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;visit[counter]&lt;/STRONG&gt; = date_of_visit;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; /*what happens when we use the array name followed by counter variable in braces assigned to a new variable?????*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;/* Output one observation per BY group (Patient_ID). */ &lt;/P&gt;&lt;P&gt;if last.patient_ID then output; &lt;/P&gt;&lt;P&gt;/* Format and drop variables, as desired. */ &lt;/P&gt;&lt;P&gt;format visit: mmddyy10.; &lt;/P&gt;&lt;P&gt;drop date_of_visit counter; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;P&gt;proc print; &lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Apr 2013 00:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100421#M28240</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-04-08T00:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing Observations using Arrays</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100422#M28241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Array &lt;STRONG&gt;visit&lt;/STRONG&gt; has 4 elements. You access an element of array&lt;STRONG&gt; visit&lt;/STRONG&gt; with the bracket notation :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;x = visit[2];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;visit[3] = y;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the first statement assigns the second element of array&lt;STRONG&gt; visit&lt;/STRONG&gt; to &lt;STRONG&gt;x&lt;/STRONG&gt;. the second statement assigns &lt;STRONG&gt;y&lt;/STRONG&gt; to the third element of array&lt;STRONG&gt; visit&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The statement &lt;STRONG&gt;call missing (of visit&lt;/STRONG&gt;&lt;LI&gt;&lt;STRONG&gt;, counter)&lt;/STRONG&gt; assigns missing values to all the elements of array&lt;STRONG&gt; visit&lt;/STRONG&gt; (the star notation means all elements) and to variable &lt;STRONG&gt;counter&lt;/STRONG&gt;. It just so happens that this is the first time variable &lt;STRONG&gt;counter&lt;/STRONG&gt; is mentioned.&lt;/LI&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Apr 2013 00:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100422#M28241</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-04-08T00:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing Observations using Arrays</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100423#M28242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks PG...&lt;/P&gt;&lt;P&gt;Good luck on your renewal of SAS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Apr 2013 03:49:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100423#M28242</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-04-08T03:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing Observations using Arrays</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100424#M28243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;I have some more questions regarding the sequence of the code ..&lt;/P&gt;&lt;P&gt;1)If it is the first of the patient then we are telling to put as MISSING.....and then telling it to do Counter+1..........instead the dataset was already set by Patient ID/........So why cant we directly say Counter+1(instead of putting a dot for the first of the patient?????????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Apr 2013 13:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100424#M28243</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-04-08T13:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing Observations using Arrays</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100425#M28244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For each patient, you want to start at counter = 1. The statement counter+1 sets the variable counter to 1, whether the previous value of counter was 0 or missing. - PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Apr 2013 15:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Collapsing-Observations-using-Arrays/m-p/100425#M28244</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-04-08T15:54:57Z</dc:date>
    </item>
  </channel>
</rss>

