<?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 convert many character variables to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172281#M301602</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My suggested is code to simply create a file that contains the names of all of the variables that need to be changed.&amp;nbsp; The rest of the suggested code takes care of changing those variables from character to numeric.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 25 May 2014 00:19:21 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2014-05-25T00:19:21Z</dc:date>
    <item>
      <title>How to convert many character variables to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172275#M301596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;I have a data set, for some reason, there are 60 character variables &lt;SPAN style="font-size: 16px;"&gt; (var1, var2, ... var60)&lt;/SPAN&gt; which they should be numeric. How to convert them to numeric? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Those variable names don't follow any pattern, they are just random names, eg, var1's name is apple, var2's name is car... etc... &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;U&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; line-height: 1.5em;"&gt;se input(var, format)&amp;nbsp; function to replace one by one is unrealistic.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; line-height: 1.5em;"&gt;There are some other variables which must remain as character, for example, organization name (which are letters ), and organization ID (which are numbers stored as character). For those 60 variables, they are numbers but somehow incorrectly stored as "character".&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 May 2014 21:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172275#M301596</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-05-24T21:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert many character variables to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172276#M301597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is one way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*create some test data*/&lt;/P&gt;&lt;P&gt;data have (drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class (rename=(height=_height&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; weight=_weight));&lt;/P&gt;&lt;P&gt;&amp;nbsp; height=put(_height, best12.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; weight=put(_weight, best12.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data variables;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length vname $32;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input vname;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;height&lt;/P&gt;&lt;P&gt;weight&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select catt(vname,"=_",vname),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catt("_",vname),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vname&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :renames separated by " ",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :vars separated by " ",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :vnames separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from variables&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have (rename=(&amp;amp;renames.));&lt;/P&gt;&lt;P&gt;&amp;nbsp; array cvars $ &amp;amp;vars;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array vars &amp;amp;vnames.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do over cvars;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vars=input(cvars,12.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 May 2014 23:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172276#M301597</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-05-24T23:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert many character variables to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172277#M301598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are there also character variables in this data set which must remain character? If so: Do we need to test first if a character variable contains only strings which can get converted or are there so few "real" character variables left that you could provide these names as input to the conversion process?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 May 2014 23:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172277#M301598</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-05-24T23:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert many character variables to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172278#M301599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are some other variables which must remain as character, for example, organization name (which are letters ), organization ID (which are numbers stored as character). For those 60 variables, they are numbers but somehow incorrectly stored as "character".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 May 2014 00:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172278#M301599</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-05-25T00:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert many character variables to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172279#M301600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Arthur! I will study the code and to see how to apply it to my data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 May 2014 00:10:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172279#M301600</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-05-25T00:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert many character variables to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172280#M301601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Removed because of incorrect statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 May 2014 00:18:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172280#M301601</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-05-25T00:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert many character variables to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172281#M301602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My suggested is code to simply create a file that contains the names of all of the variables that need to be changed.&amp;nbsp; The rest of the suggested code takes care of changing those variables from character to numeric.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 May 2014 00:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172281#M301602</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-05-25T00:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert many character variables to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172282#M301603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; :vars separated by " "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;SAS says&amp;nbsp; "missing a comma at the end of above statement". &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Problem solved. Thank you,&amp;nbsp; Arthur and Patrick!&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 May 2014 00:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172282#M301603</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-05-25T00:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert many character variables to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172283#M301604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad to see that you figured it out by yourself.&amp;nbsp; I just added the missing comma to my original post&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 May 2014 01:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172283#M301604</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-05-25T01:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert many character variables to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172284#M301605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 May 2014 01:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-many-character-variables-to-numeric/m-p/172284#M301605</guid>
      <dc:creator>Jonate_H</dc:creator>
      <dc:date>2014-05-25T01:58:34Z</dc:date>
    </item>
  </channel>
</rss>

