<?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: convert all numeric variables to character using array and vice versa in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/330980#M74336</link>
    <description>&lt;P&gt;In general, define array for all character (array ARRNAME _character_; )&lt;/P&gt;
&lt;P&gt;and then loop through all of the variables (do over ARRNAME; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but some more info on what/why would be helpful&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2017 17:17:36 GMT</pubDate>
    <dc:creator>cau83</dc:creator>
    <dc:date>2017-02-09T17:17:36Z</dc:date>
    <item>
      <title>convert all numeric variables to character using array and vice versa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/330960#M74331</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to convert all numeric data to character and and all character vars to numeric using arrray.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rajesh&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 19:22:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/330960#M74331</guid>
      <dc:creator>draroda</dc:creator>
      <dc:date>2017-02-08T19:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: convert all numeric variables to character using array and vice versa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/330966#M74333</link>
      <description>&lt;P&gt;What for?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 20:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/330966#M74333</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-08T20:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: convert all numeric variables to character using array and vice versa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/330974#M74335</link>
      <description>&lt;P&gt;If your intent is to replace the contents in the existing variables then that is not going to happen. SAS numeric variables are just that, numeric. You cannot place text into a numeric. And numeric values will get changed to text when placed into a character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need to provide a very explicit example of some start data and what the result should look like with what you are attempting to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you can associate a display format with values so the result looks like character;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc format;&lt;/P&gt;
&lt;P&gt;value yn&lt;/P&gt;
&lt;P&gt;1= 'Yes'&lt;/P&gt;
&lt;P&gt;0= 'No';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;data junk;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; input x;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc print data=junk;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var x;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; format x yn.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 20:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/330974#M74335</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-08T20:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: convert all numeric variables to character using array and vice versa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/330980#M74336</link>
      <description>&lt;P&gt;In general, define array for all character (array ARRNAME _character_; )&lt;/P&gt;
&lt;P&gt;and then loop through all of the variables (do over ARRNAME; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but some more info on what/why would be helpful&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 17:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/330980#M74336</guid>
      <dc:creator>cau83</dc:creator>
      <dc:date>2017-02-09T17:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: convert all numeric variables to character using array and vice versa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331202#M74405</link>
      <description>&lt;P&gt;I have variables a b c d with numbers values but they are of character type variable and i do not want to write any syntax repeatedly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thats why i am lookng for any macro code which can convert all character type variables to numeric variables .&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 15:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331202#M74405</guid>
      <dc:creator>draroda</dc:creator>
      <dc:date>2017-02-09T15:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: convert all numeric variables to character using array and vice versa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331245#M74418</link>
      <description>&lt;P&gt;If I understand you correctly, you have a dataset with character variables, but numeric content, and you want to convert these to numeric varables, but with the same variable names.&lt;/P&gt;
&lt;P&gt;A quick and dirty solution is to export data to CSV and import again, the import procedure vill use the same names, but determine variable type from the content:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; test;&lt;/P&gt;
&lt;P&gt;input a$ b c$ d e$ f g$ h i$ j k l m n;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;1 2 A 4 5 6 B 8 9 0 1 H 3 4&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;export&lt;/STRONG&gt; data=test dbms=csv outfile="e:\work\test.xlsx" replace;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;import&lt;/STRONG&gt; datafile="e:\work\test.xlsx" dbms=csv out=test2 replace;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 17:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331245#M74418</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2017-02-09T17:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: convert all numeric variables to character using array and vice versa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331246#M74419</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/44091"&gt;@draroda&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have variables a b c d with numbers values but they are of character type variable and i do not want to write any syntax repeatedly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thats why i am lookng for any macro code which can convert all character type variables to numeric variables .&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Maybe it is time to go back in your process and determine why those variables that you want to be numeric were created as character to begin with. Did you by any chance use PROC Import to bring the data into SAS? While helpful the procedure has to &lt;STRONG&gt;guess&lt;/STRONG&gt; what type a variable may be and some common conditions, such as the value for a column being missing in the first rows of the data or non-numeric codes such as NULL or characters such a ()&amp;nbsp;surrounding the digits will be assumed to be character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Addressing such things early often simplifies things later.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 17:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331246#M74419</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-09T17:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: convert all numeric variables to character using array and vice versa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331256#M74424</link>
      <description>&lt;P&gt;If you're looking for a universal solution (any number of character variables) SAS support has this suggestion:&amp;nbsp;&lt;A href="http://support.sas.com/kb/40/700.html" target="_blank"&gt;http://support.sas.com/kb/40/700.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's only 4 variables the repeating syntax does not seem like a big deal. i'm assuming you are dealing with more.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 17:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331256#M74424</guid>
      <dc:creator>cau83</dc:creator>
      <dc:date>2017-02-09T17:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: convert all numeric variables to character using array and vice versa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331379#M74464</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12887"&gt;@ErikLund_Jensen&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;If I understand you correctly, you have a dataset with character variables, but numeric content, and you want to convert these to numeric varables, but with the same variable names.&lt;/P&gt;
&lt;P&gt;A quick and dirty solution is to export data to CSV and import again, the import procedure vill use the same names, but determine variable type from the content:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; test;&lt;/P&gt;
&lt;P&gt;input a$ b c$ d e$ f g$ h i$ j k l m n;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;1 2 A 4 5 6 B 8 9 0 1 H 3 4&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;export&lt;/STRONG&gt; data=test dbms=csv outfile="e:\work\test.xlsx" replace;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;import&lt;/STRONG&gt; datafile="e:\work\test.xlsx" dbms=csv out=test2 replace;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Very&lt;/STRONG&gt;&amp;nbsp; bad habit to name CSV files with an XLSX extension.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a large value for GUESSINGROWS in the Import step as you may introduce or repeat character varaibles for missing values.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 23:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331379#M74464</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-09T23:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: convert all numeric variables to character using array and vice versa</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331418#M74477</link>
      <description>Sorry. It was CSV in my working code, would not work otherwise. Bad habit to copy/paste half-baked code.&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Feb 2017 07:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-all-numeric-variables-to-character-using-array-and-vice/m-p/331418#M74477</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2017-02-10T07:56:33Z</dc:date>
    </item>
  </channel>
</rss>

