<?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: Shortcut for writing an IF statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-writing-an-IF-statement/m-p/689952#M209804</link>
    <description>&lt;P&gt;That is what the ARRAY statement is for.&amp;nbsp; Also boolean expressions evaluate as 0 or 1 already.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array income income_201001-income_201012 income_201101-income_201112 ;
array flag_ [24];
do index=1 to dim(income);
  flag_[index] = income[index] &amp;gt; 0;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Oct 2020 12:42:00 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-10-08T12:42:00Z</dc:date>
    <item>
      <title>Shortcut for writing an IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-writing-an-IF-statement/m-p/689950#M209803</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking to create a single data step where I use a repetitive IF statement for 24 columns (income_201001, &lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;income_201002, income_201003 ...... ,income_201012, income_201101,income_201102 ...... income_201112)&lt;/SPAN&gt; . The first four numbers represent the year (i.e. take values 2010 or 2011) and the last two numbers represent months (1 to 12).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The IF statement I want to use is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF income_201001 &amp;gt; 0 then flag_1=1; ELSE flag_1=0;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;IF income_201002 &amp;gt; 0 then flag_2=1; ELSE flag_2=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;…&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;IF income_201111 &amp;gt; 0 then flag_23=1; ELSE flag_23=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; box-sizing: border-box; color: #333333; cursor: text; display: inline; float: none; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;IF income_201112 &amp;gt; 0 then flag_24=1; ELSE flag_24=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; box-sizing: border-box; color: #333333; cursor: text; display: inline; float: none; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;What's the quickest way to write this without having to repeat 24 lines of code?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; box-sizing: border-box; color: #333333; cursor: text; display: inline; float: none; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 12:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-writing-an-IF-statement/m-p/689950#M209803</guid>
      <dc:creator>zishaq</dc:creator>
      <dc:date>2020-10-08T12:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Shortcut for writing an IF statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-writing-an-IF-statement/m-p/689952#M209804</link>
      <description>&lt;P&gt;That is what the ARRAY statement is for.&amp;nbsp; Also boolean expressions evaluate as 0 or 1 already.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array income income_201001-income_201012 income_201101-income_201112 ;
array flag_ [24];
do index=1 to dim(income);
  flag_[index] = income[index] &amp;gt; 0;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 12:42:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shortcut-for-writing-an-IF-statement/m-p/689952#M209804</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-08T12:42:00Z</dc:date>
    </item>
  </channel>
</rss>

