<?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: If a Field Value is a Char, change to Zero in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119046#M9975</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have just tried on EG 4.3, there will be minor modification.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Query Builder --- Computed Columns --- New --- Advanced expression ---&amp;nbsp; Enter an expression as: &lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;sum(input(d,best.),0) &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;, please note that ?? have been removed (for unknown reason, EG does not like it), and &lt;STRONG&gt;d&lt;/STRONG&gt; is your original variable. --- follow the instructions till the end.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update: figure out the reason why EG doesn't like ??, actually it is Proc SQL , Query Builder will not generate data step, instead, it uses Proc SQL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Jun 2013 02:14:11 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2013-06-26T02:14:11Z</dc:date>
    <item>
      <title>If a Field Value is a Char, change to Zero</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119040#M9969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a field that contains both numbers &amp;amp; text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where the value is text, I want those values to be changed to a zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to think of a function to use in an Advanced Expression to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone suggest what I should use? Thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 00:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119040#M9969</guid>
      <dc:creator>pcfriendly</dc:creator>
      <dc:date>2013-06-26T00:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: If a Field Value is a Char, change to Zero</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119041#M9970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input d$;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;wwe&lt;/P&gt;&lt;P&gt;123&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if anydigit(d)=0 then d='0';&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or &lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input d$;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;wwe&lt;/P&gt;&lt;P&gt;w23&lt;/P&gt;&lt;P&gt;123&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; set have;&lt;/P&gt;&lt;P&gt; if anyalpha(d) then d='0';&lt;/P&gt;&lt;P&gt; proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 00:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119041#M9970</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-06-26T00:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: If a Field Value is a Char, change to Zero</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119042#M9971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or if you hence want to convert it to number:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data have;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;input d$;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;cards;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;wwe&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;123&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;num=sum(input(d,??best.),0);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 01:06:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119042#M9971</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-06-26T01:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: If a Field Value is a Char, change to Zero</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119043#M9972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will need to create a new variable to store a numeric value.&amp;nbsp; You can use INPUT() function to convert the character variable to a number and use the COALESCE()&amp;nbsp; to convert the missing values to zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;numvar = coalesce( input( charvar, ??32. ), 0 );&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 01:37:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119043#M9972</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-06-26T01:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: If a Field Value is a Char, change to Zero</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119044#M9973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Hai.Kuo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I should have mentioned I'm using the query builder &amp;amp; creating an Advanced Expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to advise an expression to do this?'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 01:42:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119044#M9973</guid>
      <dc:creator>pcfriendly</dc:creator>
      <dc:date>2013-06-26T01:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: If a Field Value is a Char, change to Zero</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119045#M9974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see no reason you can't do it in query builder, Try to 'add' a 'calculated' variable, and apply the function needed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 01:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119045#M9974</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-06-26T01:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: If a Field Value is a Char, change to Zero</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119046#M9975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have just tried on EG 4.3, there will be minor modification.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Query Builder --- Computed Columns --- New --- Advanced expression ---&amp;nbsp; Enter an expression as: &lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;sum(input(d,best.),0) &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;, please note that ?? have been removed (for unknown reason, EG does not like it), and &lt;STRONG&gt;d&lt;/STRONG&gt; is your original variable. --- follow the instructions till the end.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update: figure out the reason why EG doesn't like ??, actually it is Proc SQL , Query Builder will not generate data step, instead, it uses Proc SQL.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 02:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119046#M9975</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-06-26T02:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: If a Field Value is a Char, change to Zero</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119047#M9976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Hai.kuo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That works perfectly, can you explain what 'best' is doing? Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 21:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119047#M9976</guid>
      <dc:creator>pcfriendly</dc:creator>
      <dc:date>2013-06-26T21:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: If a Field Value is a Char, change to Zero</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119048#M9977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The BEST. is used as an informat to read the value of the variable D without asuming anything about how big/small the variable may be or number of decimal places. If D is not a numeric value then the input(d,best.) returns a missing value. In which case the sum of missing and 0 returns as 0.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 22:39:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119048#M9977</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-06-26T22:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: If a Field Value is a Char, change to Zero</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119049#M9978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks ballardw&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jun 2013 22:43:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-a-Field-Value-is-a-Char-change-to-Zero/m-p/119049#M9978</guid>
      <dc:creator>pcfriendly</dc:creator>
      <dc:date>2013-06-26T22:43:21Z</dc:date>
    </item>
  </channel>
</rss>

