<?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: SAS programming: select a numerical value with the oldest corresponding date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346554#M273206</link>
    <description>&lt;P&gt;Hi guys! thanks for all the advice!&lt;/P&gt;&lt;P&gt;Maybe this will clear up my question. So my dateset looks like this:&lt;/P&gt;&lt;P&gt;var1 &amp;nbsp; &amp;nbsp; &amp;nbsp; date1 &amp;nbsp; &amp;nbsp; &amp;nbsp;var2 &amp;nbsp; &amp;nbsp; &amp;nbsp;date2 &amp;nbsp; &amp;nbsp; &amp;nbsp;var3 &amp;nbsp; &amp;nbsp; &amp;nbsp;date3 &amp;nbsp; &amp;nbsp; &amp;nbsp; var4 &amp;nbsp; &amp;nbsp; date4 &amp;nbsp; &amp;nbsp; &amp;nbsp;....... &amp;nbsp; var16 &amp;nbsp; &amp;nbsp;date16&lt;/P&gt;&lt;P&gt;200 &amp;nbsp; &amp;nbsp;08/09/16 &amp;nbsp; &amp;nbsp; 300 &amp;nbsp; &amp;nbsp;05/02/16 &amp;nbsp; 400 &amp;nbsp; &amp;nbsp; 06/10/15 &amp;nbsp; &amp;nbsp;500 &amp;nbsp; &amp;nbsp;01/20/15 &amp;nbsp; ....... &amp;nbsp; &amp;nbsp;350 &amp;nbsp; &amp;nbsp; 02/15/05&lt;/P&gt;&lt;P&gt;250 &amp;nbsp; &amp;nbsp;07/06/16 &amp;nbsp; &amp;nbsp; 200 &amp;nbsp; &amp;nbsp;04/10/14&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so for the 1st observation my baseline would be 350 because that's value corresponding to the oldest date, and 2nd observation would be 200 because that correspond to the oldest date.&lt;/P&gt;&lt;P&gt;I want the numerical value that correspond to the oldest date to be the baseline and I need to find this baseline for each subject.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 03 Apr 2017 01:35:11 GMT</pubDate>
    <dc:creator>michan22</dc:creator>
    <dc:date>2017-04-03T01:35:11Z</dc:date>
    <item>
      <title>SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346535#M273202</link>
      <description>&lt;P&gt;Hi guys!&lt;/P&gt;&lt;P&gt;Please help me!&lt;/P&gt;&lt;P&gt;I have 106 subjects/observations and 16 numerical variables (var1-var16)&amp;nbsp;with a date corresponding to each numerical variable&amp;nbsp;(date1-date16). The date variables (and their corresponding numerical variables) are ordered so that older dates&amp;nbsp;are placed last for each subject (e.g. subject 1 may have values in all 16 numerical and date variables with 16 being the oldest, subject 2 may only have 8 numerical and date variables with 8 being the oldest).&lt;/P&gt;&lt;P&gt;Now, I need to define a baseline_var that correspond to the numerical value with the oldest date for each subject. How can I program SAS to find this baseline value?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sun, 02 Apr 2017 23:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346535#M273202</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-02T23:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346541#M273203</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_min = min(of date1-date16);
format date_min date9.l &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 00:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346541#M273203</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-04-03T00:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346545#M273204</link>
      <description>&lt;P&gt;Assuming no ties, and this is untested.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can find the largest value using the MAX function and then the corresponding index using WHICHN. I've nested these, but you may need to separate out the calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know that the last record is the largest and missing values are used for the renaming values you can also count how many missing values are present (NMISS). Then the largest index would be something like the commented out option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array vars(*) var1-var16;
array dates(*) date1-date16;

index_largest = whichn(max(of dates(*)), of dates(*)); &lt;BR /&gt;*index_largest = dim(vars) - nmiss(of vars(*)); &lt;BR /&gt;*index_largest = 16 - nmiss(of vars(*));
value = vars(index_largest);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135827"&gt;@michan22&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi guys!&lt;/P&gt;
&lt;P&gt;Please help me!&lt;/P&gt;
&lt;P&gt;I have 106 subjects/observations and 16 numerical variables (var1-var16)&amp;nbsp;with a date corresponding to each numerical variable&amp;nbsp;(date1-date16). The date variables (and their corresponding numerical variables) are ordered so that older dates&amp;nbsp;are placed last for each subject (e.g. subject 1 may have values in all 16 numerical and date variables with 16 being the oldest, subject 2 may only have 8 numerical and date variables with 8 being the oldest).&lt;/P&gt;
&lt;P&gt;Now, I need to define a baseline_var that correspond to the numerical value with the oldest date for each subject. How can I program SAS to find this baseline value?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 00:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346545#M273204</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-03T00:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346551#M273205</link>
      <description>&lt;P&gt;Obviously, a number of us are interpreting your question differently. I think the following is what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  infile cards truncover;
  input var1-var16;
  cards;
1 2 5 7 6
2 2 4 5
3 4 2 7 9
9 8 7 6 5 3 2 8 1
;

data want;
  set have;
  array nums(*) var1-var16;
  do _n_=dim(nums) to 1 by -1;
    if not missing(nums(_n_)) then do;
      want=nums(_n_);
      leave;
    end;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 00:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346551#M273205</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-03T00:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346554#M273206</link>
      <description>&lt;P&gt;Hi guys! thanks for all the advice!&lt;/P&gt;&lt;P&gt;Maybe this will clear up my question. So my dateset looks like this:&lt;/P&gt;&lt;P&gt;var1 &amp;nbsp; &amp;nbsp; &amp;nbsp; date1 &amp;nbsp; &amp;nbsp; &amp;nbsp;var2 &amp;nbsp; &amp;nbsp; &amp;nbsp;date2 &amp;nbsp; &amp;nbsp; &amp;nbsp;var3 &amp;nbsp; &amp;nbsp; &amp;nbsp;date3 &amp;nbsp; &amp;nbsp; &amp;nbsp; var4 &amp;nbsp; &amp;nbsp; date4 &amp;nbsp; &amp;nbsp; &amp;nbsp;....... &amp;nbsp; var16 &amp;nbsp; &amp;nbsp;date16&lt;/P&gt;&lt;P&gt;200 &amp;nbsp; &amp;nbsp;08/09/16 &amp;nbsp; &amp;nbsp; 300 &amp;nbsp; &amp;nbsp;05/02/16 &amp;nbsp; 400 &amp;nbsp; &amp;nbsp; 06/10/15 &amp;nbsp; &amp;nbsp;500 &amp;nbsp; &amp;nbsp;01/20/15 &amp;nbsp; ....... &amp;nbsp; &amp;nbsp;350 &amp;nbsp; &amp;nbsp; 02/15/05&lt;/P&gt;&lt;P&gt;250 &amp;nbsp; &amp;nbsp;07/06/16 &amp;nbsp; &amp;nbsp; 200 &amp;nbsp; &amp;nbsp;04/10/14&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so for the 1st observation my baseline would be 350 because that's value corresponding to the oldest date, and 2nd observation would be 200 because that correspond to the oldest date.&lt;/P&gt;&lt;P&gt;I want the numerical value that correspond to the oldest date to be the baseline and I need to find this baseline for each subject.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 01:35:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346554#M273206</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-03T01:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346556#M273207</link>
      <description>&lt;P&gt;That's precisely what the code I suggested does. The date variables are irrelevant as long as they are in date order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 01:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346556#M273207</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-03T01:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346558#M273208</link>
      <description>&lt;P&gt;Arthur.T,&lt;/P&gt;
&lt;P&gt;Use function coalesce(),no need array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards truncover;
  input var1-var16;
  cards;
1 2 5 7 6
2 2 4 5
3 4 2 7 9
9 8 7 6 5 3 2 8 1
;

data want;
  set have;
 want=coalesce(of var16-var1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 02:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346558#M273208</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-03T02:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346561#M273209</link>
      <description>&lt;P&gt;Oh my gosh thank you! this is life changing!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 02:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346561#M273209</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-03T02:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346564#M273210</link>
      <description>&lt;P&gt;&lt;FONT face="andale mono,times"&gt;By the way, why is this function called&amp;nbsp;coalesce? Just out of curiosity so it will help me to remembering it more easier.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;Thanks!&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 04:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346564#M273210</guid>
      <dc:creator>Miracle</dc:creator>
      <dc:date>2017-04-03T04:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346610#M273211</link>
      <description>&lt;PRE&gt;
I don't know. Maybe read it literally .

&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 10:08:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346610#M273211</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-03T10:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming: select a numerical value with the oldest corresponding date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346641#M273212</link>
      <description>&lt;P&gt;My guess is that it comes from the original definition in computer science, namely:&amp;nbsp;&lt;SPAN&gt;the merging of adjacent blocks of memory to fill gaps caused by deallocated memory&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 12:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-select-a-numerical-value-with-the-oldest/m-p/346641#M273212</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-03T12:22:09Z</dc:date>
    </item>
  </channel>
</rss>

