<?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 character to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807043#M318284</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The question is asking me to make a new variable called "HTC_STATn" which equals 1 is there new patients as the value and 0 is there is established patients.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;SAS return a 1 or 0 as the result of a boolean expression.&amp;nbsp; So just use:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp2;
  set demomed;
  HTC_STATn = (htc_stat= "new patient");
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 10 Apr 2022 16:21:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-04-10T16:21:51Z</dc:date>
    <item>
      <title>Converting character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807027#M318280</link>
      <description>&lt;P&gt;Was asked to make many character variables into numeric ones but cannot seem to run my code. The question is asking me to make a new variable called "HTC_STATn" which equals 1 is there new patients as the value and 0 is there is established patients.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run this code the dataset is blank&lt;/P&gt;
&lt;PRE&gt;data temp2;&lt;BR /&gt;set demomed;&lt;BR /&gt;If htc_stat= "established patient" then HTC_STATn="0";&lt;BR /&gt;If htc_stat= "new patient" then HTC_STATn= "1";&lt;BR /&gt;run; &lt;/PRE&gt;
&lt;PRE&gt;data temp2;&lt;BR /&gt;set demomed;&lt;BR /&gt;If htc_stat= "established patient" then HTC_STATn="0";&lt;BR /&gt;If htc_stat= "new patient" then HTC_STATn= "1";&lt;BR /&gt;If htc_stat= "transfer patient" then HTC_STATn= "1";&lt;BR /&gt;If hepther = "y" HEPTHERn= "1";&lt;BR /&gt;If hepther = "n" HEPTHERn= "0";&lt;BR /&gt;If Htype = "hemophilia a" then HTYPEn = "0";&lt;BR /&gt;If Htype = "hemophilia b" then HTYPEn = "1";&lt;BR /&gt;If Hlevel = 'mild' then Hleveln = "0";&lt;BR /&gt;If Hlevel = 'moderate' then Hleveln = "1";&lt;BR /&gt;If Hlevel = 'severe' then Hleveln = "2";&lt;BR /&gt;run; &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Apr 2022 14:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807027#M318280</guid>
      <dc:creator>saza</dc:creator>
      <dc:date>2022-04-10T14:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807029#M318281</link>
      <description>&lt;P&gt;The &lt;A href="http://support.sas.com/kb/60678" target="_self"&gt;CtoN macro&lt;/A&gt; is a general tool for character to numeric conversion. Your specific code just creates a new character variable with character values "0" and "1". If you want it to be numeric, remove the quotes:&lt;/P&gt;
&lt;PRE&gt;If htc_stat= "established patient" then HTC_STATn=0;&lt;BR /&gt;If htc_stat= "new patient" then HTC_STATn= 1;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Apr 2022 14:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807029#M318281</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2022-04-10T14:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807030#M318282</link>
      <description>I did there but I still am getting a syntax error stating that i'm missing symbols within if/then statements?</description>
      <pubDate>Sun, 10 Apr 2022 14:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807030#M318282</guid>
      <dc:creator>saza</dc:creator>
      <dc:date>2022-04-10T14:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807032#M318283</link>
      <description>&lt;P&gt;Please post the complete (all code and messages) by copy/pasting the log text into a window opened with this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Apr 2022 15:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807032#M318283</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-10T15:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807043#M318284</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The question is asking me to make a new variable called "HTC_STATn" which equals 1 is there new patients as the value and 0 is there is established patients.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;SAS return a 1 or 0 as the result of a boolean expression.&amp;nbsp; So just use:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp2;
  set demomed;
  HTC_STATn = (htc_stat= "new patient");
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Apr 2022 16:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807043#M318284</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-10T16:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807080#M318285</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/413742"&gt;@saza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run this code the dataset is blank&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show us the results of running Proc Contents on the data set DEMOMED.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;If the result data set is blank that strongly suggests that the source data set was as well.&lt;/P&gt;
&lt;P&gt;a bit like :&lt;/P&gt;
&lt;PRE&gt;HTC_STATn="0";&lt;/PRE&gt;
&lt;P&gt;Does not assign a numeric value to HTC_STATn but a character value of "0". A numeric assignment would look like&lt;/P&gt;
&lt;PRE&gt;HTC_STATn= 0 ;&lt;/PRE&gt;
&lt;P&gt;Also, you want to be very careful about = with character variables. "Mild" is not equal to "mild" so make sure that case is considered.&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>Mon, 11 Apr 2022 02:23:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-character-to-numeric/m-p/807080#M318285</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-11T02:23:46Z</dc:date>
    </item>
  </channel>
</rss>

