<?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 a group of numeric variables into character using an array? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863051#M340931</link>
    <description>Thanks, Reeza!&lt;BR /&gt;&lt;BR /&gt;What is the purpose of " -l" in the piece of code below?&lt;BR /&gt;&lt;BR /&gt;_new(i) = put(_old(i), best. -l);</description>
    <pubDate>Wed, 08 Mar 2023 17:45:04 GMT</pubDate>
    <dc:creator>Hello_there</dc:creator>
    <dc:date>2023-03-08T17:45:04Z</dc:date>
    <item>
      <title>How to convert a group of numeric variables into character using an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863041#M340924</link>
      <description>&lt;P&gt;Hi, this is a data manipulation exercise. Could you tell me what's wrong with my code for turning numeric variables into character using the following code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i keep getting messages about undeclared array reference&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;data have; 
infile datalines dsd dlm=",";
	input id $ var1 var2 var3;
datalines;
a, 34, 45, 12
b, 41, 92, 14
c, 92, 29, 11
;
run;

data have1; set have;
	array var[3] _numeric_;
		do i=1 to dim[_numeric_];
			new[i]=strip(put(var[i], best.));
		end;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 17:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863041#M340924</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2023-03-08T17:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a group of numeric variables into character using an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863043#M340925</link>
      <description>&lt;P&gt;You have not declared an array named NEW. So you can't assign values to it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you declare an array named VAR. Later you refer to an array as _VAR, not the same thing. So SAS doesn't like that either.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 17:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863043#M340925</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-08T17:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a group of numeric variables into character using an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863044#M340926</link>
      <description>&lt;P&gt;Could i please receive some help on how to do this? &lt;BR /&gt;I'm hitting a brick wall because usually when i do arrays i just use the same variable name as the ones i'm changing, but bc i can't use the same variable name because i'm converting numeric to characer, i don't understand what the solution is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;edit: i changed _var to var in the OP&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 17:21:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863044#M340926</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2023-03-08T17:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a group of numeric variables into character using an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863046#M340927</link>
      <description>You can't use the method you have there. How will you know what the names of the new variables will be? They cannot be the same names? So your new array needs to have the names explicitly assigned somehow.</description>
      <pubDate>Wed, 08 Mar 2023 17:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863046#M340927</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-03-08T17:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a group of numeric variables into character using an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863047#M340928</link>
      <description>Hi Reeza, so i guess it's not possible to do it more efficiently? &lt;BR /&gt;&lt;BR /&gt;I guess it would be better just to do it &lt;BR /&gt;the long way&lt;BR /&gt; new1=strip(put(var1));&lt;BR /&gt;....&lt;BR /&gt;new3=strip(put(var3));&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Mar 2023 17:23:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863047#M340928</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2023-03-08T17:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a group of numeric variables into character using an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863050#M340930</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
infile datalines dsd dlm=",";
	input id $ var1 var2 var3;
datalines;
a, 34, 45, 12
b, 41, 92, 14
c, 92, 29, 11
;
run;

data want;
set have;
array _old(*) var1-var3;
array _new(*) new_var1-new_var3;

do i=1 to dim(_old);
    _new(i) = put(_old(i), best. -l);
end;

drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Mar 2023 17:41:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863050#M340930</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-03-08T17:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a group of numeric variables into character using an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863051#M340931</link>
      <description>Thanks, Reeza!&lt;BR /&gt;&lt;BR /&gt;What is the purpose of " -l" in the piece of code below?&lt;BR /&gt;&lt;BR /&gt;_new(i) = put(_old(i), best. -l);</description>
      <pubDate>Wed, 08 Mar 2023 17:45:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863051#M340931</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2023-03-08T17:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert a group of numeric variables into character using an array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863052#M340932</link>
      <description>left alignment for the character variable to avoid weird spacing issues. &lt;BR /&gt;&lt;BR /&gt;See the documentation (PUT) for the other letters/alignments.</description>
      <pubDate>Wed, 08 Mar 2023 17:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-a-group-of-numeric-variables-into-character-using/m-p/863052#M340932</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-03-08T17:53:32Z</dc:date>
    </item>
  </channel>
</rss>

