<?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: SAS/IML equivalent to DATA step vname() function in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850357#M5928</link>
    <description>&lt;P&gt;If your goal is to obtain the name of the variable that is sent into a module, you can use the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/imlug/imlug_langref_sect329.htm" target="_self"&gt;PARENTNAME function&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml ;
start parm_names( p1, p2, p3 ) ;
  name_1 = parentname( "p1" ) ;
  name_2 = parentname( "p2" ) ;
  name_3 = parentname( "p3" ) ;
  return ( name_1 || name_2 || name_3 ) ;
finish ;

parm_name_vector = parm_names( a, b, c ) ;
print parm_name_vector;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But be aware that this is NOT the equivalent of the VNAME function. The VNAME function gets the name of the variable that corresponds to the i_th element of a variable array. I suppose the equivalent of that is to obtain the name of the i_th variable for a matrix, which is presumably why Tech Support sent you that snippet.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Dec 2022 17:44:52 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-12-19T17:44:52Z</dc:date>
    <item>
      <title>SAS/IML equivalent to DATA step vname() function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850355#M5927</link>
      <description>&lt;P&gt;Is there a SAS/IML equivalent to the DATA step vname() function?&lt;/P&gt;
&lt;P&gt;For the DATA step, I can write&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a ;
a = 1 ; b = 2 ; c = 3 ; output ;
run ;
data names ;
set a ;
name_1 = vname( a ) ; name_2 = vname( b ) ; name_3 = vname( c ) ; output ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and the dataset names contains the names of the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, for SAS/IML, suppose that I have only IML matrices whose names I want to use as arguments to other modules.. I want to create a module called parm_names that will extract the names of the variables passed as parameters:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml ;
start parm_names( p1, p2, p3 ) ;

/* what I want is the equivalent of vname() here */

name_1 = IML_equivalent_to_vname( p1 ) ;
name_2 = IML_equivalent_to_vname( p2 ) ;
name_3 = IML_equivalent_to_vname( p3 ) ;

return ( name_1 || name_2 || name_3 ) ;
finish ;

parm_name_vector = parm_names( a, b, c ) ;&lt;BR /&gt;
/* additional IML code to use the variable names */

quit ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS Tech Support suggested:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
use a;
read all into a[colname=cname];
print cname a;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but that solution presumes that the names are already available in the program data buffer of a SAS dataset, while in my IML module, I am supplying the variables as IML module parameters.&lt;/P&gt;
&lt;P&gt;Does a SAS/IML equivalent to the DATA step function vnames() exist?&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 17:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850355#M5927</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2022-12-19T17:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/IML equivalent to DATA step vname() function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850357#M5928</link>
      <description>&lt;P&gt;If your goal is to obtain the name of the variable that is sent into a module, you can use the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_033/imlug/imlug_langref_sect329.htm" target="_self"&gt;PARENTNAME function&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml ;
start parm_names( p1, p2, p3 ) ;
  name_1 = parentname( "p1" ) ;
  name_2 = parentname( "p2" ) ;
  name_3 = parentname( "p3" ) ;
  return ( name_1 || name_2 || name_3 ) ;
finish ;

parm_name_vector = parm_names( a, b, c ) ;
print parm_name_vector;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But be aware that this is NOT the equivalent of the VNAME function. The VNAME function gets the name of the variable that corresponds to the i_th element of a variable array. I suppose the equivalent of that is to obtain the name of the i_th variable for a matrix, which is presumably why Tech Support sent you that snippet.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 17:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850357#M5928</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-12-19T17:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/IML equivalent to DATA step vname() function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850368#M5929</link>
      <description>&lt;P&gt;I was not aware of the parentname() function. It does exactly what I want! Thanks, Rick.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 19:16:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850368#M5929</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2022-12-19T19:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/IML equivalent to DATA step vname() function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850385#M5930</link>
      <description>&lt;P&gt;See also&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2014/10/08/param-name-parent-env.html" target="_blank"&gt;The name of a parameter in the parent environment - The DO Loop (sas.com)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;And all SAS IML programmers should read&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2015/06/17/everything-about-modules.html" target="_blank"&gt;Everything you wanted to know about writing SAS/IML modules - The DO Loop&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 20:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850385#M5930</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-12-19T20:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/IML equivalent to DATA step vname() function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850398#M5931</link>
      <description>Very helpful references. Thanks, Rick!</description>
      <pubDate>Mon, 19 Dec 2022 21:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-equivalent-to-DATA-step-vname-function/m-p/850398#M5931</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2022-12-19T21:57:33Z</dc:date>
    </item>
  </channel>
</rss>

