<?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 Creating indicator variable for minimum value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-indicator-variable-for-minimum-value/m-p/349577#M81102</link>
    <description>&lt;P&gt;Another quick question: &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have multiple observations per ID and multiple variables (in rows) with numbers in character format; &amp;nbsp;I'm trying to find a way to create an indicator variable "min" that will indicate which observation has the smallest of the numbers (across rows)&amp;nbsp;per ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My variables are ID and Event1...Event5 (the event variables have numbers). &amp;nbsp;Does anyone have an idea on what could help? &amp;nbsp;I tried running the below but it didn't work well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA test5;
 SET test3;
 min=.;
	array x{*} ODED_date: ODHD_date: ODOO_date:;
	DO i=1 TO dim(x);
	IF x{i} LT min THEN min=1;&lt;BR /&gt;ELSE min=0;
END;
DROP i;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Apr 2017 19:45:57 GMT</pubDate>
    <dc:creator>cyoung</dc:creator>
    <dc:date>2017-04-12T19:45:57Z</dc:date>
    <item>
      <title>Creating indicator variable for minimum value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-indicator-variable-for-minimum-value/m-p/349577#M81102</link>
      <description>&lt;P&gt;Another quick question: &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have multiple observations per ID and multiple variables (in rows) with numbers in character format; &amp;nbsp;I'm trying to find a way to create an indicator variable "min" that will indicate which observation has the smallest of the numbers (across rows)&amp;nbsp;per ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My variables are ID and Event1...Event5 (the event variables have numbers). &amp;nbsp;Does anyone have an idea on what could help? &amp;nbsp;I tried running the below but it didn't work well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA test5;
 SET test3;
 min=.;
	array x{*} ODED_date: ODHD_date: ODOO_date:;
	DO i=1 TO dim(x);
	IF x{i} LT min THEN min=1;&lt;BR /&gt;ELSE min=0;
END;
DROP i;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 19:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-indicator-variable-for-minimum-value/m-p/349577#M81102</guid>
      <dc:creator>cyoung</dc:creator>
      <dc:date>2017-04-12T19:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating indicator variable for minimum value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-indicator-variable-for-minimum-value/m-p/349591#M81111</link>
      <description>&lt;P&gt;It helps to provide an example of your input data and what the result for that input may be. A data step is the best way to represent the data as then we can test something that matches you requirement. Data alread in a data set may be turned into data step code Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You mention that the values are in Event1-event5 but do not show those variables in the code. Please use variable names not descriptions in your problem statement if they are different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are likely going to nee&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 20:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-indicator-variable-for-minimum-value/m-p/349591#M81111</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-12T20:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating indicator variable for minimum value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-indicator-variable-for-minimum-value/m-p/349618#M81131</link>
      <description>&lt;P&gt;Sounds like you are trying to do something like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test3;
  informat ODED_date ODHD_date ODOO_date date9.;
  input id ODED_date ODHD_date ODOO_date;
  cards;
1 1jan2017 1jan2017 1jan2017
1 31dec2016 30nov2016 30nov2016
1 11oct2016 10jan2017 28nov2017
2 31dec2016 30nov2016 30nov2016
2 1jan2017 1jan2017 1jan2017
2 11oct2016 10jan2017 28nov2017
;

proc sql;
  create table test5 as
    select *,
      case 
        when ODED_date eq min(ODED_date) then 1
        else 0
      end as min_ODED_date,
      case 
        when ODHD_date eq min(ODHD_date) then 1
        else 0
      end as min_ODHD_date,
      case 
        when ODOO_date eq min(ODOO_date) then 1
        else 0
      end as min_ODOO_date
        from test3
          group by id
  ;
quit;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 21:37:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-indicator-variable-for-minimum-value/m-p/349618#M81131</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-12T21:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating indicator variable for minimum value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-indicator-variable-for-minimum-value/m-p/349631#M81139</link>
      <description>&lt;P&gt;This is not a difficult problem. &amp;nbsp;However, you need to spell it out a little better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You say you have variables EVENT1 - EVENT5, but then in your program you refer to entirely different names. &amp;nbsp;What are the right names to use?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. You say they are character variables. &amp;nbsp;You have to give some examples of what is actually in them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. You need to appreciate that there can be ties for the minimum value and so more than one row can be flagged with MIN=1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With answers to these questions, though, the programming is relatively easy.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 23:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-indicator-variable-for-minimum-value/m-p/349631#M81139</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-12T23:03:09Z</dc:date>
    </item>
  </channel>
</rss>

