<?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: Using Array to Change Data Type in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602013#M174240</link>
    <description>&lt;P&gt;The problem starts here:&lt;/P&gt;
&lt;PRE&gt; 76            length nvar1-nvar234 12;
                                    __
                                    352
 ERROR 352-185: The length of numeric variables is 3-8.
&lt;/PRE&gt;
&lt;P&gt;Here, you define your variables as numeric, albeit with an invalid length. Numeric variables in SAS have a maximum of 8 bytes for real number storage. But this still results in 234 numeric variables.&lt;/P&gt;
&lt;P&gt;Then, in&lt;/P&gt;
&lt;PRE&gt; 77            format nvar1-nvar234 $12.;
 WARNING: Variable nvar1 has already been defined as numeric.
 &lt;/PRE&gt;
&lt;P&gt;you try to assign a character format to those numeric variables, which is not possible.&lt;/P&gt;
&lt;P&gt;If you actually wanted to create character variables, omit the length statement completely. The format statement will suffice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you transpose your data to a long format, convert the resulting single variable to character, and transpose back (unless keeping a long format is not better in the first place).&lt;/P&gt;</description>
    <pubDate>Wed, 06 Nov 2019 15:06:52 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-11-06T15:06:52Z</dc:date>
    <item>
      <title>Using Array to Change Data Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602004#M174233</link>
      <description>&lt;P&gt;I am trying to change data type from numeric to character in my SAS table.&amp;nbsp; I keep getting an error and I don't know what's going on.&amp;nbsp; I found a previous post that was helpful but hasn't solved my issue.&amp;nbsp; It is telling me my character values have been converted to numeric which is the opposite of what I want to do and, there aren't any character values that are numbers in the table so it's not actually doing anything.&amp;nbsp; It's also telling me that my numbers are already numeric...yeah I know, I want to change that.&amp;nbsp;&amp;nbsp; Below is my code and the log.&amp;nbsp; Any suggestions would be greatly appreciated.&amp;nbsp; Thank you.&amp;nbsp; Shannan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CODE&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;data&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt; other_costs_char;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; other_costs;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; length&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; nvar1-nvar234 &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; format&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; nvar1-nvar234 &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New"&gt;$12.&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; num &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;_numeric_&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; _char(*) $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;12&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt; nvar1-nvar234;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dim(num); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _char(i) = put(num(i), &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New"&gt;best12.&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; end&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;LOG&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;WARNING: Variable nvar227 has already been defined as numeric.&lt;/P&gt;&lt;P&gt;WARNING: Variable nvar228 has already been defined as numeric.&lt;/P&gt;&lt;P&gt;WARNING: Variable nvar229 has already been defined as numeric.&lt;/P&gt;&lt;P&gt;WARNING: Variable nvar230 has already been defined as numeric.&lt;/P&gt;&lt;P&gt;WARNING: Variable nvar231 has already been defined as numeric.&lt;/P&gt;&lt;P&gt;WARNING: Variable nvar232 has already been defined as numeric.&lt;/P&gt;&lt;P&gt;WARNING: Variable nvar233 has already been defined as numeric.&lt;/P&gt;&lt;P&gt;WARNING: Variable nvar234 has already been defined as numeric.&lt;/P&gt;&lt;P&gt;992&lt;/P&gt;&lt;P&gt;993 array num _numeric_;&lt;/P&gt;&lt;P&gt;994 array _char(*) $12 nvar1-nvar234;&lt;/P&gt;&lt;P&gt;995 do i=1 to dim(num);&lt;/P&gt;&lt;P&gt;996 _char(i) = put(num(i), best12.);&lt;/P&gt;&lt;P&gt;997 end;&lt;/P&gt;&lt;P&gt;998 run;&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by:&lt;/P&gt;&lt;P&gt;(Line):(Column).&lt;/P&gt;&lt;P&gt;996:21&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;WARNING: The data set WORK.OTHER_COSTS_CHAR may be incomplete. When this step was stopped there&lt;/P&gt;&lt;P&gt;were 0 observations and 471 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.09 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.07 seconds&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 14:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602004#M174233</guid>
      <dc:creator>sbrent</dc:creator>
      <dc:date>2019-11-06T14:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using Array to Change Data Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602005#M174234</link>
      <description>&lt;P&gt;Can you link to the previous post?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, this is contradictory.. Are these variables numeric or character?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length nvar1-nvar234 12;
format nvar1-nvar234 $12.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Nov 2019 14:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602005#M174234</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-06T14:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using Array to Change Data Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602013#M174240</link>
      <description>&lt;P&gt;The problem starts here:&lt;/P&gt;
&lt;PRE&gt; 76            length nvar1-nvar234 12;
                                    __
                                    352
 ERROR 352-185: The length of numeric variables is 3-8.
&lt;/PRE&gt;
&lt;P&gt;Here, you define your variables as numeric, albeit with an invalid length. Numeric variables in SAS have a maximum of 8 bytes for real number storage. But this still results in 234 numeric variables.&lt;/P&gt;
&lt;P&gt;Then, in&lt;/P&gt;
&lt;PRE&gt; 77            format nvar1-nvar234 $12.;
 WARNING: Variable nvar1 has already been defined as numeric.
 &lt;/PRE&gt;
&lt;P&gt;you try to assign a character format to those numeric variables, which is not possible.&lt;/P&gt;
&lt;P&gt;If you actually wanted to create character variables, omit the length statement completely. The format statement will suffice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you transpose your data to a long format, convert the resulting single variable to character, and transpose back (unless keeping a long format is not better in the first place).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 15:06:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602013#M174240</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-06T15:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using Array to Change Data Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602017#M174242</link>
      <description>Here's the original post I was looking at: &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-variable/m-p/385929/highlight/true#M92383" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-variable-to-numeric-variable/m-p/385929/highlight/true#M92383&lt;/A&gt;</description>
      <pubDate>Wed, 06 Nov 2019 15:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602017#M174242</guid>
      <dc:creator>sbrent</dc:creator>
      <dc:date>2019-11-06T15:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using Array to Change Data Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602020#M174244</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp; I have removed my contradictory data type statements (removed the length statement and just left the format statement).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting a new error...&lt;/P&gt;&lt;P&gt;ERROR: Array subscript out of range at line 1037 column 21.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After which is lists ALL the data from both arrays.&amp;nbsp; I'm not sure what it means by line 1037.&amp;nbsp; The data has 39 rows and 236 columns. Then it has more error messages.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_I_=. i=235 _ERROR_=1 _N_=1&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;NOTE: There were 1 observations read from the data set WORK.OTHER_COSTS.&lt;/P&gt;&lt;P&gt;WARNING: The data set WORK.OTHER_COSTS_CHAR may be incomplete. When this step was stopped there&lt;/P&gt;&lt;P&gt;were 0 observations and 471 variables.&lt;/P&gt;&lt;P&gt;WARNING: Data set WORK.OTHER_COSTS_CHAR was not replaced because this step was stopped.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.03 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To answer the question, it has been transposed and that is the final format it needs to be exported into.&amp;nbsp; I'm trying to convert the dollar amounts in the transposed table to character so they can be combined with another table that contains header rows with descriptions.&amp;nbsp; Then the whole thing will be exported as one table into Excel where the numbers will once again become numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know, convoluted...but learning to convert in an array seemed faster than learning how to use all the various report functions that could probably accomplish the same/similar end result...and I of course have a deadline.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 15:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602020#M174244</guid>
      <dc:creator>sbrent</dc:creator>
      <dc:date>2019-11-06T15:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using Array to Change Data Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602021#M174245</link>
      <description>Forgot to add that after transpose, all the nulls are replaced with 0, just to give a clearer picture of my data.</description>
      <pubDate>Wed, 06 Nov 2019 15:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602021#M174245</guid>
      <dc:creator>sbrent</dc:creator>
      <dc:date>2019-11-06T15:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using Array to Change Data Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602022#M174246</link>
      <description>&lt;P&gt;It's running without out error (I counted my variables wrong, was one off).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I open the new table that it creates, all my variables are still numeric.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 15:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602022#M174246</guid>
      <dc:creator>sbrent</dc:creator>
      <dc:date>2019-11-06T15:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using Array to Change Data Type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602023#M174247</link>
      <description>&lt;P&gt;Your code adds new variables, but leaves the existing ones untouched.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 15:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Array-to-Change-Data-Type/m-p/602023#M174247</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-06T15:39:38Z</dc:date>
    </item>
  </channel>
</rss>

