<?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 an array to convert numeric variables to character variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256866#M49277</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;&amp;nbsp;Thank you. However, I tried that earlier w/ no effect. I just tried it again w/ your code. The PROC CONTENTS shows that they are still numeric:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;# Variable Type Len&lt;BR /&gt;351 QWB2A Num 8&lt;BR /&gt;352 QWB2B Num 8&lt;BR /&gt;353 QWB2C Num 8&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA a4_final_num;
	SET	a4_final_pre;
	
 	Array _numeric(*) 
 	QWB2A
	QWB2B
	QWB2C;
	
	Array _character(*) $ 8 var1-var3;
  
  	DO i=1 to dim(_numeric);
     _character(i) = PUT(_numeric(i),8.); 
    END;
    
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 55 &lt;BR /&gt; 56 &lt;BR /&gt; 57 DATA a4_final_num;&lt;BR /&gt; 58 SETa4_final_pre;&lt;BR /&gt; 59 &lt;BR /&gt; 60 Array _numeric(*)&lt;BR /&gt; 61 QWB2A&lt;BR /&gt; 62 QWB2B&lt;BR /&gt; 63 QWB2C;&lt;BR /&gt; 64 &lt;BR /&gt; 65 Array _character(*) $ 8 var1-var3;&lt;BR /&gt; 66 &lt;BR /&gt; 67 DO i=1 to dim(_numeric);&lt;BR /&gt; 68 _character(i) = PUT(_numeric(i),8.);&lt;BR /&gt; 69 END;&lt;BR /&gt; 70 &lt;BR /&gt; 71 RUN;&lt;BR /&gt; &lt;BR /&gt; NOTE: There were 404 observations read from the data set WORK.A4_FINAL_PRE.&lt;BR /&gt; NOTE: The data set WORK.A4_FINAL_NUM has 404 observations and 495 variables.&lt;BR /&gt; NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 0.05 seconds&lt;BR /&gt; cpu time 0.05 seconds&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; 72 &lt;BR /&gt; 73 PROC CONTENTS DATA=a4_final_num (KEEP=QWB2A&lt;BR /&gt; 74 QWB2B&lt;BR /&gt; 75 QWB2C);&lt;BR /&gt; 76 RUN;&lt;BR /&gt; &lt;BR /&gt; NOTE: PROCEDURE CONTENTS used (Total process time):&lt;BR /&gt; real time 0.10 seconds&lt;BR /&gt; cpu time 0.08 seconds&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; 77 &lt;BR /&gt; 78 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 90&lt;/P&gt;</description>
    <pubDate>Tue, 15 Mar 2016 18:22:42 GMT</pubDate>
    <dc:creator>_maldini_</dc:creator>
    <dc:date>2016-03-15T18:22:42Z</dc:date>
    <item>
      <title>Using an array to convert numeric variables to character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256859#M49275</link>
      <description>&lt;P&gt;Why is this code not converting numeric variables to character variables? In fact, the log says it is doing the opposite, although a PROC CONTENTS reveals no conversion actually took place. Thank you for the assistance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA a4_final_num;
	SET	a4_final_pre;&lt;BR /&gt;
 	Array _numeric(*) 
 	QWB2A
	QWB2B
	QWB2C;
	
	Array _character(*) var1-var3;
  
  	DO i=1 to dim(_numeric);
     _character(i) = PUT(_numeric(i),8.); 
    END;
    
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 55 &lt;BR /&gt; 56 DATA a4_final_num;&lt;BR /&gt; 57 SETa4_final_pre;&lt;BR /&gt; 58 &lt;BR /&gt; 59 Array _numeric(*)&lt;BR /&gt; 60 QWB2A&lt;BR /&gt; 61 QWB2B&lt;BR /&gt; 62 QWB2C;&lt;BR /&gt; 63 &lt;BR /&gt; 64 Array _character(*) var1-var3;&lt;BR /&gt; 65 &lt;BR /&gt; 66 DO i=1 to dim(_numeric);&lt;BR /&gt; 67 _character(i) = PUT(_numeric(i),8.);&lt;BR /&gt; 68 END;&lt;BR /&gt; 69 &lt;BR /&gt; 70 RUN;&lt;BR /&gt; &lt;BR /&gt; NOTE: &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Character values have been converted to numeric values&lt;/STRONG&gt;&lt;/FONT&gt; at the places given by: (Line):(Column).&lt;BR /&gt; 67:6&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 17:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256859#M49275</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2016-03-15T17:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array to convert numeric variables to character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256860#M49276</link>
      <description>&lt;P&gt;By default, the second ARRAY statement defines VAR1-VAR3 as numeric.&amp;nbsp; You can control that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array _character (3) $ 8 var1-var3;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 18:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256860#M49276</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-15T18:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array to convert numeric variables to character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256866#M49277</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;&amp;nbsp;Thank you. However, I tried that earlier w/ no effect. I just tried it again w/ your code. The PROC CONTENTS shows that they are still numeric:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;# Variable Type Len&lt;BR /&gt;351 QWB2A Num 8&lt;BR /&gt;352 QWB2B Num 8&lt;BR /&gt;353 QWB2C Num 8&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA a4_final_num;
	SET	a4_final_pre;
	
 	Array _numeric(*) 
 	QWB2A
	QWB2B
	QWB2C;
	
	Array _character(*) $ 8 var1-var3;
  
  	DO i=1 to dim(_numeric);
     _character(i) = PUT(_numeric(i),8.); 
    END;
    
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 55 &lt;BR /&gt; 56 &lt;BR /&gt; 57 DATA a4_final_num;&lt;BR /&gt; 58 SETa4_final_pre;&lt;BR /&gt; 59 &lt;BR /&gt; 60 Array _numeric(*)&lt;BR /&gt; 61 QWB2A&lt;BR /&gt; 62 QWB2B&lt;BR /&gt; 63 QWB2C;&lt;BR /&gt; 64 &lt;BR /&gt; 65 Array _character(*) $ 8 var1-var3;&lt;BR /&gt; 66 &lt;BR /&gt; 67 DO i=1 to dim(_numeric);&lt;BR /&gt; 68 _character(i) = PUT(_numeric(i),8.);&lt;BR /&gt; 69 END;&lt;BR /&gt; 70 &lt;BR /&gt; 71 RUN;&lt;BR /&gt; &lt;BR /&gt; NOTE: There were 404 observations read from the data set WORK.A4_FINAL_PRE.&lt;BR /&gt; NOTE: The data set WORK.A4_FINAL_NUM has 404 observations and 495 variables.&lt;BR /&gt; NOTE: DATA statement used (Total process time):&lt;BR /&gt; real time 0.05 seconds&lt;BR /&gt; cpu time 0.05 seconds&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; 72 &lt;BR /&gt; 73 PROC CONTENTS DATA=a4_final_num (KEEP=QWB2A&lt;BR /&gt; 74 QWB2B&lt;BR /&gt; 75 QWB2C);&lt;BR /&gt; 76 RUN;&lt;BR /&gt; &lt;BR /&gt; NOTE: PROCEDURE CONTENTS used (Total process time):&lt;BR /&gt; real time 0.10 seconds&lt;BR /&gt; cpu time 0.08 seconds&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; 77 &lt;BR /&gt; 78 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;BR /&gt; 90&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 18:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256866#M49277</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2016-03-15T18:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array to convert numeric variables to character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256869#M49280</link>
      <description>&lt;P&gt;Yes, that's true.&amp;nbsp; VAR1-VAR3 are now character where they used to be numeric.&amp;nbsp; But none of your code changes the existing variables, it only assigns values to new variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could add this to your DATA step if your goal is to save the original variables (and using the original variable names) as character:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;drop QWB2A QWB2B QWB2C;&lt;/P&gt;
&lt;P&gt;rename var1=QWB2A var2=QWB2B var3=QWB2C;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a strange looking combination, but it does work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 18:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256869#M49280</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-15T18:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array to convert numeric variables to character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256871#M49281</link>
      <description>Thanks! That makes sense.</description>
      <pubDate>Tue, 15 Mar 2016 18:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-array-to-convert-numeric-variables-to-character/m-p/256871#M49281</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2016-03-15T18:49:40Z</dc:date>
    </item>
  </channel>
</rss>

