<?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 a Series of Indicator Variables Based on a Set of Criteria in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Series-of-Indicator-Variables-Based-on-a-Set-of/m-p/209083#M38818</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;I would like to create a long series of indicator variables based on a set of criteria. The code I am using looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H6&gt;data test;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sample;&lt;/H6&gt;&lt;H6&gt;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array ind[91];&lt;/H6&gt;&lt;H6&gt;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(ind);&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do test=1 to 10 by 0.1;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ind&lt;I&gt; = (tenure &amp;gt;= test and risk="low" and value="low");&lt;/I&gt;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/H6&gt;&lt;H6&gt;run;&lt;/H6&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The basic idea is to create &lt;EM&gt;ind1 &lt;/EM&gt;to &lt;EM&gt;ind99&lt;/EM&gt; based on whether tenure is greater than or equal to the test counter and whether the levels of &lt;EM&gt;risk&lt;/EM&gt; and &lt;EM&gt;value&lt;/EM&gt; are low. Running this, I seem to be getting 0s for the indicator variables created, even when the values for a particular record meet the criteria. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a secondary matter, I would like to ideally generalize this because I two other value levels for &lt;EM&gt;risk&lt;/EM&gt; (medium and high) and 4 other value levels for &lt;EM&gt;value&lt;/EM&gt;. My approach now is to create other sets of array variables for the other combinations of &lt;EM&gt;risk&lt;/EM&gt; and &lt;EM&gt;value&lt;/EM&gt;. But I suspect there is a better way. Would a multidimensional array help here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dhrumil Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Aug 2015 21:14:54 GMT</pubDate>
    <dc:creator>dhrumil_patel</dc:creator>
    <dc:date>2015-08-27T21:14:54Z</dc:date>
    <item>
      <title>Creating a Series of Indicator Variables Based on a Set of Criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Series-of-Indicator-Variables-Based-on-a-Set-of/m-p/209083#M38818</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;I would like to create a long series of indicator variables based on a set of criteria. The code I am using looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H6&gt;data test;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sample;&lt;/H6&gt;&lt;H6&gt;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array ind[91];&lt;/H6&gt;&lt;H6&gt;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(ind);&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do test=1 to 10 by 0.1;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ind&lt;I&gt; = (tenure &amp;gt;= test and risk="low" and value="low");&lt;/I&gt;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/H6&gt;&lt;H6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/H6&gt;&lt;H6&gt;run;&lt;/H6&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The basic idea is to create &lt;EM&gt;ind1 &lt;/EM&gt;to &lt;EM&gt;ind99&lt;/EM&gt; based on whether tenure is greater than or equal to the test counter and whether the levels of &lt;EM&gt;risk&lt;/EM&gt; and &lt;EM&gt;value&lt;/EM&gt; are low. Running this, I seem to be getting 0s for the indicator variables created, even when the values for a particular record meet the criteria. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a secondary matter, I would like to ideally generalize this because I two other value levels for &lt;EM&gt;risk&lt;/EM&gt; (medium and high) and 4 other value levels for &lt;EM&gt;value&lt;/EM&gt;. My approach now is to create other sets of array variables for the other combinations of &lt;EM&gt;risk&lt;/EM&gt; and &lt;EM&gt;value&lt;/EM&gt;. But I suspect there is a better way. Would a multidimensional array help here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dhrumil Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 21:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Series-of-Indicator-Variables-Based-on-a-Set-of/m-p/209083#M38818</guid>
      <dc:creator>dhrumil_patel</dc:creator>
      <dc:date>2015-08-27T21:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Series of Indicator Variables Based on a Set of Criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Series-of-Indicator-Variables-Based-on-a-Set-of/m-p/209084#M38819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why do you need all these indicator variables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At any rate, why loop through it all? Set the array default to&amp;nbsp; and only start setting to 1 when tenure=test for starters.&lt;/P&gt;&lt;P&gt;Second, you can use do loops to loop over character values. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do value="low", "medium", "high";&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 21:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Series-of-Indicator-Variables-Based-on-a-Set-of/m-p/209084#M38819</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-08-27T21:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Series of Indicator Variables Based on a Set of Criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-Series-of-Indicator-Variables-Based-on-a-Set-of/m-p/224422#M40333</link>
      <description>&lt;P&gt;As written your loop&lt;/P&gt;&lt;P&gt;do test=1 to 10 by 0.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; ind&lt;I&gt; = (tenure &amp;gt;= test and risk="low" and value="low");&lt;/I&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) does not properly reference the array, to refernce an element of the array you want something like: ind[i] = (&amp;lt;code goes here&amp;gt;);&lt;/P&gt;&lt;P&gt;2) is only ever going to yield the result for test= 10&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 15:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-Series-of-Indicator-Variables-Based-on-a-Set-of/m-p/224422#M40333</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-09-08T15:33:56Z</dc:date>
    </item>
  </channel>
</rss>

