<?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: variable name and array in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/variable-name-and-array/m-p/10960#M1144</link>
    <description>Just wondering...&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000201956.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000201956.htm&lt;/A&gt;&lt;BR /&gt;
        &lt;BR /&gt;
are you seeing any warning messages in the SAS log. ABS is the name of a SAS function.&lt;BR /&gt;
doc for ABS function:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000245861.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000245861.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
       &lt;BR /&gt;
 It says in the doc:&lt;BR /&gt;
  &lt;B&gt;&lt;BR /&gt;
CAUTION:&lt;BR /&gt;
Using the name of a SAS function as an array name can cause unpredictable results. &lt;BR /&gt;
             &lt;BR /&gt;
If you inadvertently use a function name as the name of the array, SAS treats parenthetical references that involve the name as array references, not function references, for the duration of the DATA step. A warning message is written to the SAS log.  &lt;BR /&gt;
&lt;/B&gt;&lt;BR /&gt;
   &lt;BR /&gt;
As for your question about creating a new character variable, then this code shows how to use the VNAME function to grab the variable name of an array member.&lt;BR /&gt;
 &lt;BR /&gt;
[pre]&lt;BR /&gt;
7714  data makearr;&lt;BR /&gt;
7715    length newcharvar $15;&lt;BR /&gt;
7716    set sashelp.class(obs=2);&lt;BR /&gt;
7717    array allnum _numeric_;&lt;BR /&gt;
7718    do i = 1 to dim(allnum);&lt;BR /&gt;
7719      varname = vname(allnum(i));&lt;BR /&gt;
7720      newcharvar = cats('_',put(_n_,2.0),'_',put(i,2.0),'_xxx_',trim(varname));&lt;BR /&gt;
7721      putlog _n_= i= name= varname= newcharvar=;&lt;BR /&gt;
7722    end;&lt;BR /&gt;
7723&lt;BR /&gt;
7724  run;&lt;BR /&gt;
                          &lt;BR /&gt;
_N_=1 i=1 Name=Alfred varname=Age newcharvar=_1_1_xxx_Age&lt;BR /&gt;
_N_=1 i=2 Name=Alfred varname=Height newcharvar=_1_2_xxx_Height&lt;BR /&gt;
_N_=1 i=3 Name=Alfred varname=Weight newcharvar=_1_3_xxx_Weight&lt;BR /&gt;
_N_=2 i=1 Name=Alice varname=Age newcharvar=_2_1_xxx_Age&lt;BR /&gt;
_N_=2 i=2 Name=Alice varname=Height newcharvar=_2_2_xxx_Height&lt;BR /&gt;
_N_=2 i=3 Name=Alice varname=Weight newcharvar=_2_3_xxx_Weight&lt;BR /&gt;
NOTE: There were 2 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
    <pubDate>Mon, 04 Oct 2010 16:44:42 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-10-04T16:44:42Z</dc:date>
    <item>
      <title>variable name and array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/variable-name-and-array/m-p/10959#M1143</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am working with sas arrays I want to output a value and variable name and value in one column that has a value greater than say 10.&lt;BR /&gt;
&lt;BR /&gt;
I am running sas code similar to this : &lt;BR /&gt;
&lt;BR /&gt;
data temp; set temp2;&lt;BR /&gt;
&lt;BR /&gt;
array abs{*} _numeric_;&lt;BR /&gt;
&lt;BR /&gt;
do i = 1 to dim(abs);&lt;BR /&gt;
if(abs(i) &amp;gt; 10) then variable_gr10 = x1|| ... here i want to append name of the variable&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Is  there any way I could simply get name of the particular variable and append it with another value in the  data ? &lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Mon, 04 Oct 2010 16:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/variable-name-and-array/m-p/10959#M1143</guid>
      <dc:creator>rickw</dc:creator>
      <dc:date>2010-10-04T16:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: variable name and array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/variable-name-and-array/m-p/10960#M1144</link>
      <description>Just wondering...&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000201956.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000201956.htm&lt;/A&gt;&lt;BR /&gt;
        &lt;BR /&gt;
are you seeing any warning messages in the SAS log. ABS is the name of a SAS function.&lt;BR /&gt;
doc for ABS function:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000245861.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000245861.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
       &lt;BR /&gt;
 It says in the doc:&lt;BR /&gt;
  &lt;B&gt;&lt;BR /&gt;
CAUTION:&lt;BR /&gt;
Using the name of a SAS function as an array name can cause unpredictable results. &lt;BR /&gt;
             &lt;BR /&gt;
If you inadvertently use a function name as the name of the array, SAS treats parenthetical references that involve the name as array references, not function references, for the duration of the DATA step. A warning message is written to the SAS log.  &lt;BR /&gt;
&lt;/B&gt;&lt;BR /&gt;
   &lt;BR /&gt;
As for your question about creating a new character variable, then this code shows how to use the VNAME function to grab the variable name of an array member.&lt;BR /&gt;
 &lt;BR /&gt;
[pre]&lt;BR /&gt;
7714  data makearr;&lt;BR /&gt;
7715    length newcharvar $15;&lt;BR /&gt;
7716    set sashelp.class(obs=2);&lt;BR /&gt;
7717    array allnum _numeric_;&lt;BR /&gt;
7718    do i = 1 to dim(allnum);&lt;BR /&gt;
7719      varname = vname(allnum(i));&lt;BR /&gt;
7720      newcharvar = cats('_',put(_n_,2.0),'_',put(i,2.0),'_xxx_',trim(varname));&lt;BR /&gt;
7721      putlog _n_= i= name= varname= newcharvar=;&lt;BR /&gt;
7722    end;&lt;BR /&gt;
7723&lt;BR /&gt;
7724  run;&lt;BR /&gt;
                          &lt;BR /&gt;
_N_=1 i=1 Name=Alfred varname=Age newcharvar=_1_1_xxx_Age&lt;BR /&gt;
_N_=1 i=2 Name=Alfred varname=Height newcharvar=_1_2_xxx_Height&lt;BR /&gt;
_N_=1 i=3 Name=Alfred varname=Weight newcharvar=_1_3_xxx_Weight&lt;BR /&gt;
_N_=2 i=1 Name=Alice varname=Age newcharvar=_2_1_xxx_Age&lt;BR /&gt;
_N_=2 i=2 Name=Alice varname=Height newcharvar=_2_2_xxx_Height&lt;BR /&gt;
_N_=2 i=3 Name=Alice varname=Weight newcharvar=_2_3_xxx_Weight&lt;BR /&gt;
NOTE: There were 2 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 04 Oct 2010 16:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/variable-name-and-array/m-p/10960#M1144</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-10-04T16:44:42Z</dc:date>
    </item>
  </channel>
</rss>

