<?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: change from character to numeric for a column/variable in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/change-from-character-to-numeric-for-a-column-variable/m-p/89613#M625</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try using the code below as an example to write your own code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input DualClass $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;yes&lt;/P&gt;&lt;P&gt;no&lt;/P&gt;&lt;P&gt;YES&lt;/P&gt;&lt;P&gt;No&lt;/P&gt;&lt;P&gt;NO&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data have(drop=DualClass rename=(_DualClass=DualClass));&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if upcase(compress(DualClass))='YES' then _DualClass=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if upcase(compress(DualClass))='NO' then _DualClass=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jun 2012 13:02:03 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2012-06-22T13:02:03Z</dc:date>
    <item>
      <title>change from character to numeric for a column/variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/change-from-character-to-numeric-for-a-column-variable/m-p/89611#M623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Sir,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish to merge several files with similar variables but certain variables are defined as character in one file but as numeric in another file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to standardize all these variables from character to numeric, ie Yes=1, No/others=0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do i do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls refer to file attached:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg: DualClass variable -in character- yes or no need to convert to yes=1, no=0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;other variables are BLANKCHECK CBOARD LSPMT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls kindly assist. Thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 02:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/change-from-character-to-numeric-for-a-column-variable/m-p/89611#M623</guid>
      <dc:creator>mei</dc:creator>
      <dc:date>2012-06-22T02:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: change from character to numeric for a column/variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/change-from-character-to-numeric-for-a-column-variable/m-p/89612#M624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can i use input function, or should i create a dummy variable first to 1 and 0 say name it as DualClassDummy. Then i will drop the original variable DualClass and rename dualclass dummy as dual class? (so that i can do further merging with the rest of the files?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 02:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/change-from-character-to-numeric-for-a-column-variable/m-p/89612#M624</guid>
      <dc:creator>mei</dc:creator>
      <dc:date>2012-06-22T02:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: change from character to numeric for a column/variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/change-from-character-to-numeric-for-a-column-variable/m-p/89613#M625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try using the code below as an example to write your own code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input DualClass $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;yes&lt;/P&gt;&lt;P&gt;no&lt;/P&gt;&lt;P&gt;YES&lt;/P&gt;&lt;P&gt;No&lt;/P&gt;&lt;P&gt;NO&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data have(drop=DualClass rename=(_DualClass=DualClass));&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if upcase(compress(DualClass))='YES' then _DualClass=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if upcase(compress(DualClass))='NO' then _DualClass=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 13:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/change-from-character-to-numeric-for-a-column-variable/m-p/89613#M625</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-06-22T13:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: change from character to numeric for a column/variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/change-from-character-to-numeric-for-a-column-variable/m-p/89614#M626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... what do you want is a value is MISSING, another MISSING or consider it a NO (using two of your yes/no variables)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this makes MISSING = MISSING ...&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input (dualclass carveout) (:$3.) ;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;yes .&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;no NO&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;YES .&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;. YES&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;NO yes&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc format;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;invalue yn(upcase) &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;'YES' = 1 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;'NO' = 0 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;other = . ;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;set have;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;_dualclass = input(dualclass,yn.);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;_carveout&amp;nbsp; = input(carveout,yn.);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with a lot of yes/no variables, this might save some keystrokes ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;set have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;array old(*) &amp;lt;list all the y/n variables&amp;gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;array new(*) &amp;lt;list all the new variables ... same order as old&amp;gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;do _n_=1 to dim(old);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; new(_n_) = input(old(_n_),yn.);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 14:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/change-from-character-to-numeric-for-a-column-variable/m-p/89614#M626</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-06-22T14:22:39Z</dc:date>
    </item>
  </channel>
</rss>

