<?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 variables to numeric in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Converting-character-variables-to-numeric/m-p/905514#M40452</link>
    <description>&lt;P&gt;Something along the line of below sample code should do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.ps2renamed;
  x41=1;
  y='Yes';
  output;
  Y='No';
  output;
run;

proc format;
  invalue yn_char2num(upcase)
    'Y','YES' = 1
    'N','NO'  = 0
    other =.
    ;
run;

data work.ps2renamed;
  set work.ps2renamed(rename=(y=y_char));
  y=input(y_char,yn_char2num.);
  drop y_char;
run;

proc print data=work.ps2renamed;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1701404127155.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90531iE3AE1FB55F8737CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1701404127155.png" alt="Patrick_0-1701404127155.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1701404215807.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90532i4178DB699A0A5E30/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1701404215807.png" alt="Patrick_0-1701404215807.png" /&gt;&lt;/span&gt;&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>Fri, 01 Dec 2023 04:17:58 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2023-12-01T04:17:58Z</dc:date>
    <item>
      <title>Converting character variables to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-character-variables-to-numeric/m-p/905510#M40451</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to do a proc glmselect with all the variable interactions. However, I have a log error message telling me that the y variable does not match the type prescribed in the list. I know that it is because my y variable is a character variable (it is binary) while all the Xs are numeric. What code exactly should I use to convert this y variable into a numeric variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Screenshot 1: The log message&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ps2-question1.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90528i61F13643F4BF449F/image-size/large?v=v2&amp;amp;px=999" role="button" title="ps2-question1.PNG" alt="ps2-question1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Screenshot 2: The SAS code in question&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ps2-question1.screenshot2.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90529iACE6F791C96D4689/image-size/large?v=v2&amp;amp;px=999" role="button" title="ps2-question1.screenshot2.PNG" alt="ps2-question1.screenshot2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The list of variables and their attributes for dataset "ps2renamed"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ps2-question1.screenshot3.PNG" style="width: 319px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90530iF8BD9BA403CBA808/image-size/large?v=v2&amp;amp;px=999" role="button" title="ps2-question1.screenshot3.PNG" alt="ps2-question1.screenshot3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you! (Btw, I'm SAS On Demand for Academics)&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 03:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-character-variables-to-numeric/m-p/905510#M40451</guid>
      <dc:creator>SIMMII</dc:creator>
      <dc:date>2023-12-01T03:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Converting character variables to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-character-variables-to-numeric/m-p/905514#M40452</link>
      <description>&lt;P&gt;Something along the line of below sample code should do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.ps2renamed;
  x41=1;
  y='Yes';
  output;
  Y='No';
  output;
run;

proc format;
  invalue yn_char2num(upcase)
    'Y','YES' = 1
    'N','NO'  = 0
    other =.
    ;
run;

data work.ps2renamed;
  set work.ps2renamed(rename=(y=y_char));
  y=input(y_char,yn_char2num.);
  drop y_char;
run;

proc print data=work.ps2renamed;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1701404127155.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90531iE3AE1FB55F8737CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1701404127155.png" alt="Patrick_0-1701404127155.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1701404215807.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90532i4178DB699A0A5E30/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1701404215807.png" alt="Patrick_0-1701404215807.png" /&gt;&lt;/span&gt;&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>Fri, 01 Dec 2023 04:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-character-variables-to-numeric/m-p/905514#M40452</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-01T04:17:58Z</dc:date>
    </item>
  </channel>
</rss>

