<?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: How to change entire dataset from character to numeric in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-change-entire-dataset-from-character-to-numeric/m-p/626049#M20331</link>
    <description>&lt;P&gt;Here is one way using call execute:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
a = "1"; b = "12.3"; c = "";
output;
run;

data _null_;
if 0 then set have;
array _c _character_;
length _l $200;
call execute ("data want; set have;"); 
do _i = 1 to dim(_c);
 	_l = cat("_", vname(_c{_i}), "=input(", vname(_c{_i}), ",best.);drop ", 
 		vname(_c{_i}), ";rename _", vname(_c{_i}), "=", vname(_c{_i}), ";");
 	call execute (_l);
	end;
call execute ("run;");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It reads all your fields with the best. informat.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Feb 2020 04:19:36 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-02-20T04:19:36Z</dc:date>
    <item>
      <title>How to change entire dataset from character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-change-entire-dataset-from-character-to-numeric/m-p/626011#M20318</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I change my entire dataset from character to numeric??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the code on how to do one variable at a time but is there a code for the whole dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using SAS 9.4 for windowing environments!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 21:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-change-entire-dataset-from-character-to-numeric/m-p/626011#M20318</guid>
      <dc:creator>stephanicurry</dc:creator>
      <dc:date>2020-02-19T21:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to change entire dataset from character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-change-entire-dataset-from-character-to-numeric/m-p/626022#M20323</link>
      <description>&lt;P&gt;You might want to consider changing the way the data set was created, rather than changing the variables. If the data was read from Excel or from a .csv file, then changing the manner of import (or changing the Excel file/.csv file itself) might be the best and easiest solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, you'd have to write a macro that loops through all variables and creates new numeric variables based upon the old character variable values. For example: &lt;A href="https://communities.sas.com/t5/General-SAS-Programming/How-to-convert-many-character-variables-to-numeric-using-a-macro/td-p/163307" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/How-to-convert-many-character-variables-to-numeric-using-a-macro/td-p/163307&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 22:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-change-entire-dataset-from-character-to-numeric/m-p/626022#M20323</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-19T22:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to change entire dataset from character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-change-entire-dataset-from-character-to-numeric/m-p/626049#M20331</link>
      <description>&lt;P&gt;Here is one way using call execute:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
a = "1"; b = "12.3"; c = "";
output;
run;

data _null_;
if 0 then set have;
array _c _character_;
length _l $200;
call execute ("data want; set have;"); 
do _i = 1 to dim(_c);
 	_l = cat("_", vname(_c{_i}), "=input(", vname(_c{_i}), ",best.);drop ", 
 		vname(_c{_i}), ";rename _", vname(_c{_i}), "=", vname(_c{_i}), ";");
 	call execute (_l);
	end;
call execute ("run;");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It reads all your fields with the best. informat.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 04:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-change-entire-dataset-from-character-to-numeric/m-p/626049#M20331</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-02-20T04:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to change entire dataset from character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-change-entire-dataset-from-character-to-numeric/m-p/626059#M20333</link>
      <description>&lt;P&gt;Go back and revisit the process that got you in this mess. Depending on your data source, it can be very easy to fix this at the point where the data enters your SAS environment.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 06:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-change-entire-dataset-from-character-to-numeric/m-p/626059#M20333</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-20T06:37:09Z</dc:date>
    </item>
  </channel>
</rss>

