<?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: Compare columns and make one column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321716#M271021</link>
    <description>&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; firstdate = .;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; array datex {3} dateofadmin dateofdrug dateofmed;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do i=1 to 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if datex(i) ne . then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if firstdate = . &amp;nbsp;then firstdate = datex(i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if datex(i) &amp;lt; firstdate &amp;nbsp;then&amp;nbsp;&lt;SPAN&gt;firstdate = datex(i);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end; end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Dec 2016 09:29:34 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2016-12-30T09:29:34Z</dc:date>
    <item>
      <title>Compare columns and make one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321711#M271020</link>
      <description>&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6528iBF5B1A7000236A0B/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="data.PNG" title="data.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all the experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I find the earliest date within dateofadmin, dateofdrug and dateofmed for each ID using SAS code?&lt;/P&gt;&lt;P&gt;(ex. the earliest date for ID110 is dateofadmin&lt;SPAN&gt;14842 &amp;nbsp;((&lt;/SPAN&gt;14842&amp;lt;18390 and ignore the ".")) &amp;nbsp; &amp;nbsp;)&lt;/P&gt;&lt;P&gt;and then i want to put the earliest in a new column :S&amp;nbsp;&lt;/P&gt;&lt;P&gt;the date has been transfer into numeric format already.&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, i couldnt find the ways to compare numbers within columns :S&lt;/P&gt;&lt;P&gt;Please kindly give me a hint , would really be appreciated!&lt;img id="catmad" class="emoticon emoticon-catmad" src="https://communities.sas.com/i/smilies/16x16_cat-mad.png" alt="Cat Mad" title="Cat Mad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2016 08:56:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321711#M271020</guid>
      <dc:creator>weiwei2392</dc:creator>
      <dc:date>2016-12-30T08:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: Compare columns and make one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321716#M271021</link>
      <description>&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; firstdate = .;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; array datex {3} dateofadmin dateofdrug dateofmed;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do i=1 to 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if datex(i) ne . then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if firstdate = . &amp;nbsp;then firstdate = datex(i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if datex(i) &amp;lt; firstdate &amp;nbsp;then&amp;nbsp;&lt;SPAN&gt;firstdate = datex(i);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end; end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2016 09:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321716#M271021</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-12-30T09:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Compare columns and make one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321726#M271022</link>
      <description>&lt;P&gt;The MIN function should ignore missing values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;earliest_date = min(dateofadmin, dateofdrug, dateofmed);&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2016 11:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321726#M271022</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-30T11:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Compare columns and make one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321791#M271023</link>
      <description>&lt;P&gt;The min function accepts any number of arguments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
firstdate = min(dateofadmin, dateofdrug, dateofmed);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Dec 2016 20:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321791#M271023</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-12-30T20:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Compare columns and make one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321867#M271024</link>
      <description>&lt;P&gt;thank you so much!&lt;/P&gt;&lt;P&gt;Now i have one more question&lt;/P&gt;&lt;P&gt;what if i wanna add one more column "where" is states where does the first date comes from?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;like,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6548i9CD4F7ECA95AA025/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="擷取.PNG" title="擷取.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jan 2017 05:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321867#M271024</guid>
      <dc:creator>weiwei2392</dc:creator>
      <dc:date>2017-01-01T05:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Compare columns and make one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321869#M271025</link>
      <description>&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; firstdate = .;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; array datex {3} dateofadmin dateofdrug dateofmed;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do i=1 to 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if datex(i) ne . then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if firstdate = . &amp;nbsp;then do;&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; &lt;STRONG&gt;firstdate&lt;/STRONG&gt; = datex(i);&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; &lt;STRONG&gt;where = vname(datex(i)); &amp;nbsp; &lt;/STRONG&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if datex(i) &amp;lt; firstdate &amp;nbsp;then&amp;nbsp;&lt;SPAN&gt;firstdate = datex(i);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end; end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jan 2017 05:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321869#M271025</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-01T05:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Compare columns and make one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321872#M271026</link>
      <description>&lt;P&gt;It's possible to shorten the code by a line or two using arrays, but this variation might be easier to understand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;earliest_date = min(dateofadmin, dateofdrug, dateofmed);&lt;/P&gt;
&lt;P&gt;length varname $ 32;&lt;/P&gt;
&lt;P&gt;if earliest_date &amp;gt; . then select (whichn(earliest_date, dateofadmin, dateofdrug, dateofmed));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; when (1) varname='dateofadmin';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; when (2) varname='dateofdrug';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; when (3) varname='dateofmed';&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jan 2017 13:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-columns-and-make-one-column/m-p/321872#M271026</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-01T13:59:53Z</dc:date>
    </item>
  </channel>
</rss>

