<?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: Conversion from text to number in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369833#M2821</link>
    <description>&lt;P&gt;What do you mean by transformed? &amp;nbsp;If you want to replace the text "Active" with the text "1" then:&lt;/P&gt;
&lt;PRE&gt;var=tranwrd(var,"Active","1");&lt;/PRE&gt;
&lt;P&gt;But if you want a numeric variable then you have to rename, create a new one:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have (rename=(var=old_var));
  var=ifn(old_var="Active",1,0);
run;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Jun 2017 11:43:39 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-06-23T11:43:39Z</dc:date>
    <item>
      <title>Conversion from text to number</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369818#M2818</link>
      <description>&lt;P&gt;Hi everybody!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my dataset, for every customer I have the corresponding column&amp;nbsp;with "Active" or "Passive"&lt;/P&gt;&lt;P&gt;How can I convert them in Active = 0 and Passive = 1 on SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank&amp;nbsp;you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 11:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369818#M2818</guid>
      <dc:creator>Alessandra_005</dc:creator>
      <dc:date>2017-06-23T11:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion from text to number</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369820#M2819</link>
      <description>&lt;P&gt;So you have a character column and want it displayed as 1 or 0, then a proc format and apply that to your column would be simplest. &amp;nbsp;Alternatively create new column and rename:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  num_col=ifn(char_col="Active",1,0);
run;&lt;/PRE&gt;
&lt;P&gt;Its useful to post test data in the form of a datastep and what you want the output to look like otherwise we are just guessing.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 11:09:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369820#M2819</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-23T11:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion from text to number</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369822#M2820</link>
      <description>&lt;P&gt;At first, thank you from the prompt reply.&lt;/P&gt;&lt;P&gt;My dataset look like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;curtomer &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Status&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Active&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Passive&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Passive&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Passive&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Active&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Active&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ect. so I want Passive and Active to be transformed in 0 and 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 11:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369822#M2820</guid>
      <dc:creator>Alessandra_005</dc:creator>
      <dc:date>2017-06-23T11:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion from text to number</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369833#M2821</link>
      <description>&lt;P&gt;What do you mean by transformed? &amp;nbsp;If you want to replace the text "Active" with the text "1" then:&lt;/P&gt;
&lt;PRE&gt;var=tranwrd(var,"Active","1");&lt;/PRE&gt;
&lt;P&gt;But if you want a numeric variable then you have to rename, create a new one:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have (rename=(var=old_var));
  var=ifn(old_var="Active",1,0);
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Jun 2017 11:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369833#M2821</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-23T11:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion from text to number</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369835#M2822</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input customer status $;
cards;
1 Active
2 Passive
3 Passive
4 Passive
5 Active
6 Active
;
run;

proc format library=work;
invalue stat
  "Active" = 1
  "Passive" = 0
  other = -1
;
value $stat
  "Active" = '1'
  "Passive" = '0'
  other = '.'
;
run;

data want;
set have;
stat_num = input(status,stat.);
stat_num2 = ifn(status="Active",1,0);
format status $stat.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note how I presented your example data in a form that allows for easy recreation through a simple copy/paste and run.&lt;/P&gt;
&lt;P&gt;You see three possible methods for achieving your objective, the last by not changing/setting any value at all, but by applying a display format.&lt;/P&gt;
&lt;P&gt;Which method you use depends on the format in which you want to have the 0s and 1s.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 11:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conversion-from-text-to-number/m-p/369835#M2822</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-23T11:46:55Z</dc:date>
    </item>
  </channel>
</rss>

