<?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: Perplexing Parentname Proclivity in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Perplexing-Parentname-Proclivity/m-p/852033#M5944</link>
    <description>&lt;P&gt;Thanks, Rick. You have explained my perplexity perfectly. This topic 1) explains some of the mechanism of IML parameter passing works and 2) would make a great exam question!&lt;/P&gt;</description>
    <pubDate>Tue, 03 Jan 2023 21:56:24 GMT</pubDate>
    <dc:creator>rbettinger</dc:creator>
    <dc:date>2023-01-03T21:56:24Z</dc:date>
    <item>
      <title>Perplexing Parentname Proclivity</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Perplexing-Parentname-Proclivity/m-p/852017#M5942</link>
      <description>&lt;P&gt;I am interested in parsing a module's parameters for parameter type and&amp;nbsp; name. I get expected results from the type function, but the parentname function demonstrates unexpected results. Here is a test module that I have written to present my findings:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml ;
start test( p1, p2, p3, p4, p5=, p6=, p7= ) ;
name1 = parentname( 'p1' ) ;
name2 = parentname( 'p2' ) ;
name3 = parentname( 'p3' ) ;
name4 = parentname( 'p4' ) ;
name5 = parentname( 'p5' ) ;
name6 = parentname( 'p6' ) ;
name7 = parentname( 'p7' ) ;

if isEmpty( p5 )
then print p1 name1 p2 name2, p3 name3 p4 name4 ;
else print p1 name1 p2 name2, p3 name3 p4 name4, p5 name5 p6 name6, p7 name7 ;
finish ;

ab = 'ab' ;
cd = 'cd' ;
ef = 'ef' ;
gg = { ab ab cd cd ef ef gg } ;

print 'Test case 1: All parameter names reported correctly.' ;
run test( ab, cd, ef, gg ) ;

print 'Test case 2: Second occurrence of duplicated names, e.g., ( ab, ab ) reported as blank',
'e.g., name[2,4] ought to be "ab", "cd" and not blank.' ;
run test( ab, ab, cd, cd ) ;

print 'Test case 3: Attempt to teach IML to report Elizabethan sonnet rhyme scheme is futile',
'e.g., name[2,4,6] are all blank and not "ab", "cd", and "ef".' ;
run test( ab, ab, cd, cd, ef, ef, gg ) ;

quit ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the output from the program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Test case 1: All parameter names reported correctly.
p1 	name1 	p2 	name2
ab 	ab 	cd 	cd
p3 	name3 	p4 	  	name4
ef 	ef 	AB 	AB 	CD 	CD 	EF 	EF 	GG 	gg
Test case 2: Second occurrence of duplicated names, e.g., ( ab, ab ) reported as blank
e.g., name[2,4] ought to be "ab", "cd" and not blank.
p1 	name1 	p2 	name2
ab 	ab 	ab 	&amp;nbsp;
p3 	name3 	p4 	name4
cd 	cd 	cd 	&amp;nbsp;
Test case 3: Attempt to teach IML to report Elizabethan sonnet rhyme scheme is futile
e.g., name[2,4,6] are all blank and not "ab", "cd", and "ef".
p1 	name1 	p2 	name2
ab 	ab 	ab 	&amp;nbsp;
p3 	name3 	p4 	name4
cd 	cd 	cd 	&amp;nbsp;
p5 	name5 	p6 	name6
ef 	ef 	ef 	&amp;nbsp;
p7 	  	name7
AB 	AB 	CD 	CD 	EF 	EF 	GG 	gg
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Can someone explain parentname's perplexing performance?&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;Ross&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 19:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Perplexing-Parentname-Proclivity/m-p/852017#M5942</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2023-01-03T19:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Perplexing Parentname Proclivity</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Perplexing-Parentname-Proclivity/m-p/852032#M5943</link>
      <description>&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/imlug/imlug_programstatements_sect014.htm" target="_self"&gt;Arguments to modules are passed by reference, not by value&lt;/A&gt;.&amp;nbsp; This means that the module can change the value of an argument. Because of this, special care is taken if the programmer passes in the same symbol for two different arguments.&amp;nbsp; For example, consider the following example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start foo(x, y);
   x = 3;
   y = 4;
finish;

A = 1;
run foo(A, A);
print A;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is the value of A after calling the module? Remember, A was passed to both arguments! Is the value 3 or 4? Should the answer depend on the order of the statements in the body of the module?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IML resolves this ambiguity by passing A into the first argument and a COPY of A into the second argument. So the result is similar to if you were to call the module as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run foo(A, A+0);&amp;nbsp;&amp;nbsp; /* second arg is a temporary var */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This rule is based on "pass by reference," but it affects PARENTNAME. The first argument has a parentname (which is 'A'), and the second argument is a temporary variable, so PARENTNAME returns ' ' [blank].&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 21:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Perplexing-Parentname-Proclivity/m-p/852032#M5943</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-01-03T21:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Perplexing Parentname Proclivity</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Perplexing-Parentname-Proclivity/m-p/852033#M5944</link>
      <description>&lt;P&gt;Thanks, Rick. You have explained my perplexity perfectly. This topic 1) explains some of the mechanism of IML parameter passing works and 2) would make a great exam question!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 21:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Perplexing-Parentname-Proclivity/m-p/852033#M5944</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2023-01-03T21:56:24Z</dc:date>
    </item>
  </channel>
</rss>

