<?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: Array Not Working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-Not-Working/m-p/793321#M254253</link>
    <description>&lt;P&gt;You defined the variables as NUMERIC.&amp;nbsp; So you cannot put the character string the PUT() function generates into them.&lt;/P&gt;
&lt;P&gt;If you want to attach the formats to the existing numeric variables just use a FORMAT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mri1;
  set mri2 ;
  format 
    rvfat_area_corr rsat_area_corr rbmi rtotal_pfat rtotal_plean quartile.
    nswhitematter sevwhitematter mildatrophy sevatrophy bppills anticoag cat.
    diab diabtrt cvd hypt horm difcat.
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to make character variables then you need to make NEW variables, like you did for the others.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array var3 rvfat_area_corr rsat_area_corr rbmi rtotal_pfat rtotal_plean;
array var3F $2 new_rvfat_area_corr new_rsat_area_corr new_rbmi new_rtotal_pfat new_rtotal_plean;
do i=1 to dim(var3);
  var3f[i]= put(var3[i],quartile.);
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 29 Jan 2022 23:50:02 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-01-29T23:50:02Z</dc:date>
    <item>
      <title>Array Not Working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Not-Working/m-p/793320#M254252</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;Proc format;
value  quartile 0= 'Q1'
		        1= 'Q2'
				2= 'Q3'
				3= 'Q4';
value educ      1-4='&amp;lt; High School'
                5= 'High School/GED'
				6-7 = '&amp;gt;High school &amp;lt; 4-year college'
				8-11= ' &amp;gt;=4-year college';
value race     1= 'American Indian/Alaskan Native'
               2= 'Asian'
			   3= 'Native Hawaiian/Other'
			   4= 'Black'
			   5= 'White'
			   6= 'Multiple'
			   9='Unknown/Not Reported';
value smoke  0= 'Never Smoked'
             1= 'Past Smoker'
			 2= 'Current Smoker';
value hrt   1= 'E-Alone HT'
            2= 'E- Alone Placebo'
            3= ' E+P HT'
            4= 'E+ P Placeb';
value exercise
            1= 'No Activity'
			2='Some Activity of Limited Duration'
			3='2 to &amp;lt;4 Episodes per Week'
            4= '&amp;gt;= Episodes per week';
value cat 
            1= 'Yes'
			2= 'No'
            .= 'Missing';

value difcat  0= 'No'
            1= 'Yes'
			.= 'Missing';
run;


*Converting numeric values to character values;

data mri1;
set mri2 ;
array var3 rvfat_area_corr rsat_area_corr rbmi rtotal_pfat rtotal_plean;
do i=1 to dim(var3);
var3(i)= put(var3(i),quartile.);
end;
array var1 nswhitematter sevwhitematter mildatrophy sevatrophy bppills anticoag;
do i=1 to dim(var1);
var1(i)= put(var1(i), cat.);
end;
array var2 diab diabtrt cvd hypt horm;
do i=1 to dim(var2);
var2(i)= put(var2(i), difcat.);
end;
new_educ=put(educ, educ.);
race= put(racenih, race.);
new_smoke= put(smoking,smoke.);
hrtassign= put(hrtarm, hrt.);
exercise= put(lmsepi, exercise.);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hello! I want to convert several numeric variables into character variables. I thought it would be practical to use arrays for the ones that I want to format in the same way. However, the array does not appear to be working. This message appears in my log:&amp;nbsp;&amp;nbsp;Character values have been converted to numeric values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;181:1 185:1 189:1&lt;BR /&gt;NOTE: Invalid numeric data, 'Q3' , at line 181 column 10.&amp;nbsp; &amp;nbsp;and several other places as well. I was wondering what I was doing incorrectly when i created the arrays. Thank you in advance for your help!!&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jan 2022 23:22:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Not-Working/m-p/793320#M254252</guid>
      <dc:creator>zaldarsa</dc:creator>
      <dc:date>2022-01-29T23:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Array Not Working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Not-Working/m-p/793321#M254253</link>
      <description>&lt;P&gt;You defined the variables as NUMERIC.&amp;nbsp; So you cannot put the character string the PUT() function generates into them.&lt;/P&gt;
&lt;P&gt;If you want to attach the formats to the existing numeric variables just use a FORMAT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mri1;
  set mri2 ;
  format 
    rvfat_area_corr rsat_area_corr rbmi rtotal_pfat rtotal_plean quartile.
    nswhitematter sevwhitematter mildatrophy sevatrophy bppills anticoag cat.
    diab diabtrt cvd hypt horm difcat.
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to make character variables then you need to make NEW variables, like you did for the others.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array var3 rvfat_area_corr rsat_area_corr rbmi rtotal_pfat rtotal_plean;
array var3F $2 new_rvfat_area_corr new_rsat_area_corr new_rbmi new_rtotal_pfat new_rtotal_plean;
do i=1 to dim(var3);
  var3f[i]= put(var3[i],quartile.);
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Jan 2022 23:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Not-Working/m-p/793321#M254253</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-29T23:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Array Not Working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Not-Working/m-p/793325#M254256</link>
      <description>&lt;P&gt;Thank you! I follow your second suggestion, and it worked fine!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 00:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Not-Working/m-p/793325#M254256</guid>
      <dc:creator>zaldarsa</dc:creator>
      <dc:date>2022-01-30T00:22:22Z</dc:date>
    </item>
  </channel>
</rss>

