<?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 MISSING INDICATOR TRUE/FALSE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MISSING-INDICATOR-TRUE-FALSE/m-p/472337#M121104</link>
    <description>&lt;P&gt;hi all ,&lt;/P&gt;&lt;P&gt;i saw someone try to flag ,from my presumtion on data step.&lt;/P&gt;&lt;P&gt;not the original code ,but i have tried to create ,what i saw.highlighted in yellow is what am specifically looking for.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt; noprint;&lt;/P&gt;&lt;P&gt;select count(*) into:cnt from sashelp.class;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; have;&lt;/P&gt;&lt;P&gt;set sashelp.class(keep=name sex age);&lt;/P&gt;&lt;P&gt;if _n_=&amp;amp;cnt then do;&lt;/P&gt;&lt;P&gt;a=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;b='c';&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;age_ind=age=age;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;a_ind_1=a=a;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;a_ind_2=a=&lt;STRONG&gt;.&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;b_ind_1=b=b;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;b_ind_2=b=" ";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;Question 1: why does age_ind=age=age flags all 1?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question 2: why does a_ind_1=a=a flags all 1.(please see in xlsx attached)?(same as question 1)&lt;/P&gt;&lt;P&gt;Question 3: why does a_ind_2=a=. flags all 1 but the last( which is not missing) 0?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is it some TRUE/FALSE logic going on here??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jun 2018 00:36:58 GMT</pubDate>
    <dc:creator>himalayancat</dc:creator>
    <dc:date>2018-06-22T00:36:58Z</dc:date>
    <item>
      <title>MISSING INDICATOR TRUE/FALSE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MISSING-INDICATOR-TRUE-FALSE/m-p/472337#M121104</link>
      <description>&lt;P&gt;hi all ,&lt;/P&gt;&lt;P&gt;i saw someone try to flag ,from my presumtion on data step.&lt;/P&gt;&lt;P&gt;not the original code ,but i have tried to create ,what i saw.highlighted in yellow is what am specifically looking for.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt; noprint;&lt;/P&gt;&lt;P&gt;select count(*) into:cnt from sashelp.class;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; have;&lt;/P&gt;&lt;P&gt;set sashelp.class(keep=name sex age);&lt;/P&gt;&lt;P&gt;if _n_=&amp;amp;cnt then do;&lt;/P&gt;&lt;P&gt;a=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;b='c';&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;age_ind=age=age;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;a_ind_1=a=a;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;a_ind_2=a=&lt;STRONG&gt;.&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;b_ind_1=b=b;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;b_ind_2=b=" ";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;Question 1: why does age_ind=age=age flags all 1?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question 2: why does a_ind_1=a=a flags all 1.(please see in xlsx attached)?(same as question 1)&lt;/P&gt;&lt;P&gt;Question 3: why does a_ind_2=a=. flags all 1 but the last( which is not missing) 0?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is it some TRUE/FALSE logic going on here??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 00:36:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MISSING-INDICATOR-TRUE-FALSE/m-p/472337#M121104</guid>
      <dc:creator>himalayancat</dc:creator>
      <dc:date>2018-06-22T00:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: MISSING INDICATOR TRUE/FALSE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MISSING-INDICATOR-TRUE-FALSE/m-p/472339#M121105</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/140319"&gt;@himalayancat&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;is it some TRUE/FALSE logic going on here?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yes, there is.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What code like &lt;SPAN&gt;&lt;EM&gt;age_ind=age=age;&lt;/EM&gt; does:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. Logical expression &lt;EM&gt;age=age&lt;/EM&gt;&amp;nbsp; returns value of 1 if TRUE and 0 if False&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. Assigns value to variable age_ind&amp;nbsp; on the left.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;....and because age=age is always TRUE age_ind will always be set to 1.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Unlike to other languages a single equal sign is used for both logical expressions and value assignments to variables so the code can look a bit confusing.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For clarity it would may be better to formulate such logic like:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;age_ind =&amp;nbsp; (age EQ age);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 00:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MISSING-INDICATOR-TRUE-FALSE/m-p/472339#M121105</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-06-22T00:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: MISSING INDICATOR TRUE/FALSE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MISSING-INDICATOR-TRUE-FALSE/m-p/472500#M121159</link>
      <description>&lt;P&gt;You might want to compare:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff6600"&gt;a_ind_2=a=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#ff6600"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#ff6600"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;with&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;a_ind_2alt = missing(a);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;and &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#ff6600"&gt;b_ind_2=b=" ";&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;with&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;b_ind_2al= missing(b);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;SAS by default returns 1 for "true" and 0 for "false" when evaluating and comparison on the right side of an assignment. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;So for non-trivial, your a=a for example, this can be a slightly faster execution (and shorter code)than:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;if a=. then a_ind_2=1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;else a_ind_2=0.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Something along those lines is very common when creating indicator variables or flags or other dichotomous results.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 14:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MISSING-INDICATOR-TRUE-FALSE/m-p/472500#M121159</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-22T14:36:29Z</dc:date>
    </item>
  </channel>
</rss>

