<?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 character variables to numeric except for one in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/converting-all-character-variables-to-numeric-except-for-one/m-p/582947#M13903</link>
    <description>&lt;P&gt;Sure, use VNAME() to get the variable name. But you only have 10 variables, it's just as easy to list them, if the variable you want to exclude is first or last it's much easier as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that when doing type conversion in SAS you need to store them in a new variable so you'll have to create the new variable names anyways. In that case you may as well just list them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or it's usually easier to go back and fix your import, if that was the issue, and read in the data correctly the first time.&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 old(*) $ _character_;
array new(*) $ new_varname1 new_varname2 ..... new_varname10;

do i=1 to dim(old);&lt;BR /&gt;if vname(old(i)) ne 'VariableName2Exclude' then 
new(i) = input(old(i), 8.);
end;

run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2019 19:07:35 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-08-21T19:07:35Z</dc:date>
    <item>
      <title>converting all character variables to numeric except for one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-character-variables-to-numeric-except-for-one/m-p/582942#M13901</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 10 variables in my dataset that are character.&amp;nbsp; 9 of them should be numeric.&amp;nbsp; Is there a solution using array that would convert the 9 to numeric? like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array xx _character_;&lt;/P&gt;&lt;P&gt;do over xx;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;if variable is not what I want, leave it alone, else convert to numeric&amp;gt;;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 18:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-character-variables-to-numeric-except-for-one/m-p/582942#M13901</guid>
      <dc:creator>jffeudo86</dc:creator>
      <dc:date>2019-08-21T18:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: converting all character variables to numeric except for one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-character-variables-to-numeric-except-for-one/m-p/582947#M13903</link>
      <description>&lt;P&gt;Sure, use VNAME() to get the variable name. But you only have 10 variables, it's just as easy to list them, if the variable you want to exclude is first or last it's much easier as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that when doing type conversion in SAS you need to store them in a new variable so you'll have to create the new variable names anyways. In that case you may as well just list them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or it's usually easier to go back and fix your import, if that was the issue, and read in the data correctly the first time.&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 old(*) $ _character_;
array new(*) $ new_varname1 new_varname2 ..... new_varname10;

do i=1 to dim(old);&lt;BR /&gt;if vname(old(i)) ne 'VariableName2Exclude' then 
new(i) = input(old(i), 8.);
end;

run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 19:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-character-variables-to-numeric-except-for-one/m-p/582947#M13903</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-21T19:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: converting all character variables to numeric except for one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-character-variables-to-numeric-except-for-one/m-p/582950#M13904</link>
      <description>I learned a new thing today, vname. Thank you!&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Aug 2019 19:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-character-variables-to-numeric-except-for-one/m-p/582950#M13904</guid>
      <dc:creator>jffeudo86</dc:creator>
      <dc:date>2019-08-21T19:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: converting all character variables to numeric except for one</title>
      <link>https://communities.sas.com/t5/New-SAS-User/converting-all-character-variables-to-numeric-except-for-one/m-p/582994#M13911</link>
      <description>&lt;P&gt;If you wanted the variables to be numeric why were they character to begin with?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 20:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/converting-all-character-variables-to-numeric-except-for-one/m-p/582994#M13911</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-21T20:51:11Z</dc:date>
    </item>
  </channel>
</rss>

