<?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: COnverting missing variables to 0 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/340024#M63203</link>
    <description>&lt;P&gt;Perhaps&lt;/P&gt;
&lt;P&gt;Else if&amp;nbsp;&lt;STRONG&gt;missing(&lt;/STRONG&gt;&amp;nbsp;brand)&amp;nbsp; then mid =0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have many of these types of operations to do you might consider a custom informat.&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
invalue missingtext
. = 0
other=1;
run;

data example;
   x= ' ';
   yx=input(x,missingtext.);
   z='anything';
   yz=input(z,missingtext.);
run;&lt;/PRE&gt;
&lt;P&gt;This informat looks at an input string, if it is missing then the result is 0 anything else is 1. Even if the input string has a leading blank the result is one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your use then you would have&lt;/P&gt;
&lt;P&gt;mid=input(brand,missingtext.);&lt;/P&gt;
&lt;P&gt;NOTE this works if you are interested in knowing that your variable has some text.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2017 16:17:09 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-03-10T16:17:09Z</dc:date>
    <item>
      <title>COnverting missing variables to 0</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/339871#M63192</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;To convert categorical variables to numbers I have used the following code in my program&lt;BR /&gt;&lt;BR /&gt;If brand="minute.maid" then mid=1;&lt;BR /&gt;Else if brand =^"minte.maid" then mid =0;&lt;BR /&gt;&lt;BR /&gt;But in the output for mid variable all the fileds with 1 are appearing and fields with 0 are appearing missing values.&lt;BR /&gt;&lt;BR /&gt;Inorder to evade this I have used options missing ="0"&lt;BR /&gt;&lt;BR /&gt;But while I am proc reg funtion the zero values are still getting considered as missing variables only.&lt;BR /&gt;&lt;BR /&gt;How to get rid of this problem?&lt;BR /&gt;&lt;BR /&gt;(Sent from handheld device please bear with typos)</description>
      <pubDate>Fri, 10 Mar 2017 03:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/339871#M63192</guid>
      <dc:creator>sree0203</dc:creator>
      <dc:date>2017-03-10T03:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: COnverting missing variables to 0</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/339874#M63193</link>
      <description>&lt;P&gt;You have the characters in reverse order. &amp;nbsp;To get "not equal" you can use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ne&lt;/P&gt;
&lt;P&gt;^=&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But not:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;=^&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 04:10:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/339874#M63193</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-10T04:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: COnverting missing variables to 0</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/339889#M63194</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130060"&gt;@sree0203&lt;/a&gt; wrote:&lt;BR /&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But in the output for mid variable all the fileds with 1 are appearing and &lt;STRONG&gt;fields with 0 are appearing missing values.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Inorder to evade this I have used options missing ="0"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No, it means you have missing values not 0, which indicates something is wrong with your code. Fix your IF/THEN statement as indicated by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;so you get 0's not missing values.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 05:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/339889#M63194</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-10T05:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: COnverting missing variables to 0</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/339947#M63199</link>
      <description>&lt;P&gt;Simplfy your if statement and you will get the correct answer. &amp;nbsp;Binary choices are best mae using ifn/ifc:&lt;/P&gt;
&lt;PRE&gt;mid=ifn(brand="minute.maid",1,0);
&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Mar 2017 09:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/339947#M63199</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-10T09:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: COnverting missing variables to 0</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/340024#M63203</link>
      <description>&lt;P&gt;Perhaps&lt;/P&gt;
&lt;P&gt;Else if&amp;nbsp;&lt;STRONG&gt;missing(&lt;/STRONG&gt;&amp;nbsp;brand)&amp;nbsp; then mid =0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have many of these types of operations to do you might consider a custom informat.&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
invalue missingtext
. = 0
other=1;
run;

data example;
   x= ' ';
   yx=input(x,missingtext.);
   z='anything';
   yz=input(z,missingtext.);
run;&lt;/PRE&gt;
&lt;P&gt;This informat looks at an input string, if it is missing then the result is 0 anything else is 1. Even if the input string has a leading blank the result is one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your use then you would have&lt;/P&gt;
&lt;P&gt;mid=input(brand,missingtext.);&lt;/P&gt;
&lt;P&gt;NOTE this works if you are interested in knowing that your variable has some text.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 16:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/COnverting-missing-variables-to-0/m-p/340024#M63203</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-10T16:17:09Z</dc:date>
    </item>
  </channel>
</rss>

