<?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 all the variables from character to numeric together in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663608#M22793</link>
    <description>&lt;P&gt;This is a case where you can't afford to be lazy.&amp;nbsp; You have to actually examine the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS made these variables character for a reason.&amp;nbsp; Here are examples of values that might appear in the data, that SAS would have to treat as character:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt; 5&lt;/P&gt;
&lt;P&gt;N/A&lt;/P&gt;
&lt;P&gt;+ 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In real life, there will be many more examples.&amp;nbsp; You have to examine the data and decide what the right numeric value would be.&amp;nbsp; Here's how you do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;tables char_var;&lt;/P&gt;
&lt;P&gt;where input(char_var, ??8.) = .;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will show you all the values that could not be converted to numeric.&amp;nbsp; Examine them, decide what the right "decision" would be about how to store them as numeric.&amp;nbsp; Then we can talk about programming.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jun 2020 21:06:10 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2020-06-19T21:06:10Z</dc:date>
    <item>
      <title>converting all the variables from character to numeric together</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663514#M22784</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset which have character variables. I want all the variables converted to numeric together with a code. I want the code which makes all the variables to numeric together.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 14:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663514#M22784</guid>
      <dc:creator>Smitha9</dc:creator>
      <dc:date>2020-06-19T14:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: converting all the variables from character to numeric together</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663516#M22785</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array char(*) $ _character_;
array num(*) var1-Var10;

do i = 1 to dim(char);
if char(i) ne . then num(i)=input(char(i),best.);
end;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jun 2020 15:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663516#M22785</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-06-19T15:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: converting all the variables from character to numeric together</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663519#M22786</link>
      <description>&lt;P&gt;Often such a question relates to a problem or mistake made when bringing the data into SAS.&lt;/P&gt;
&lt;P&gt;So, how did you read the data into SAS to begin with?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And ALL character variables or some variables?&lt;/P&gt;
&lt;P&gt;Do you expect to have the same variable name when the process is finished? Once a SAS variable is created the type cannot change.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 15:16:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663519#M22786</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-19T15:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: converting all the variables from character to numeric together</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663531#M22787</link>
      <description>most of them are character variables which are meant to be numeric&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jun 2020 15:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663531#M22787</guid>
      <dc:creator>Smitha9</dc:creator>
      <dc:date>2020-06-19T15:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: converting all the variables from character to numeric together</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663536#M22788</link>
      <description>I have three character variables which needs to be numeric. pincode,dateofbirth and platenumber.&lt;BR /&gt;how could i put these 3variables in this code to convert all these to numeric?&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jun 2020 16:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663536#M22788</guid>
      <dc:creator>Smitha9</dc:creator>
      <dc:date>2020-06-19T16:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: converting all the variables from character to numeric together</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663539#M22789</link>
      <description>&lt;P&gt;Please try the below code for pincode and platenumber for conversion from character to numeric but for dateofbirth, we need to follow different approach inorder to read the date with a informat and then convert to numeric as in the code. Hope this helps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array char(*) $ pincode platenumber;
array num(*) pincoden platenumbern;
do i = 1 to dim(char);
if char(i) ne . then num(i)=input(char(i),best.);
end;
dateofbirth=input(dateofbirth,anydtdte.);
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jun 2020 16:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663539#M22789</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-06-19T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: converting all the variables from character to numeric together</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663541#M22790</link>
      <description>Did you import your data from a CSV or text file? If so, you should fix it at that stage and not after the fact. If you've read it in correctly from the source you can't correct it after the fact because you don't have it. Albeit, that's less likely when you've read them in as character field unless it was accidentally truncated.</description>
      <pubDate>Fri, 19 Jun 2020 16:19:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663541#M22790</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-19T16:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: converting all the variables from character to numeric together</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663559#M22791</link>
      <description>imported from csv file. how can i fix it in that stage? can you let me know? thanks</description>
      <pubDate>Fri, 19 Jun 2020 17:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663559#M22791</guid>
      <dc:creator>Smitha9</dc:creator>
      <dc:date>2020-06-19T17:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: converting all the variables from character to numeric together</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663560#M22792</link>
      <description>When you used proc import the code was written to the log. Go find that code and modify the properties of the variables you want fixed. Apply the proper informat, format and length if needed.</description>
      <pubDate>Fri, 19 Jun 2020 17:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663560#M22792</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-19T17:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: converting all the variables from character to numeric together</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663608#M22793</link>
      <description>&lt;P&gt;This is a case where you can't afford to be lazy.&amp;nbsp; You have to actually examine the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS made these variables character for a reason.&amp;nbsp; Here are examples of values that might appear in the data, that SAS would have to treat as character:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt; 5&lt;/P&gt;
&lt;P&gt;N/A&lt;/P&gt;
&lt;P&gt;+ 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In real life, there will be many more examples.&amp;nbsp; You have to examine the data and decide what the right numeric value would be.&amp;nbsp; Here's how you do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;tables char_var;&lt;/P&gt;
&lt;P&gt;where input(char_var, ??8.) = .;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will show you all the values that could not be converted to numeric.&amp;nbsp; Examine them, decide what the right "decision" would be about how to store them as numeric.&amp;nbsp; Then we can talk about programming.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 21:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-the-variables-from-character-to-numeric-together/m-p/663608#M22793</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-06-19T21:06:10Z</dc:date>
    </item>
  </channel>
</rss>

