<?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 IML Module Parameter Parsing Perplexities in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Module-Parameter-Parsing-Perplexities/m-p/851075#M5932</link>
    <description>&lt;P&gt;I am writing an IML module with 10 parameters defined. The first parameter is mandatory and the remaining nine are optional. I want to extract the names of numeric parameters.&lt;/P&gt;
&lt;P&gt;If I use only nine parameters, I have no trouble using the parentname() function to access a parameter and store its name.&lt;/P&gt;
&lt;P&gt;But if I use all 10 parameters, then I cannot extract the first nine and I can access only the tenth parameter.&lt;/P&gt;
&lt;P&gt;The following code defines a module with 10 parameters and two test cases: the first test case uses nine parameters and works properly. The second test case uses 10 parameters and returns a blank for the parameter name which I change to a '.' for sake of visibility. In the second case, only the name of the last parameter is returned properly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                                                                                                                                       
proc iml ;                                                                                                                              
reset noname spaces=1 ;                                                                                                                                                                                                                                                        
start test( p1, p2=, p3=, p4=, p5=, p6=, p7=, p8=, p9=, p10= ) ;                                                                                                                                                                                                   
print '*** nine-parameter case ***' ;                                                                                                                                                                                                                                        
free p parm_name ;                                                                                                                                                                                                                                                          
p = 'p1' : 'p9' ;                                                                                                                                                                                                                                                         
print p ;                                                                                                                                                                                                                                                                
do i = 1 to ncol( p ) ;                                                                                                                 
        parm_value = parentname( p[ i ] ) ;                                                                                             
        if parm_value = ' ' then parm_value = '.' ;                                                                                     
        parm_name = parm_name || parm_value ;                                                                                           
end ;                                                                                                                                                                                                                                                                          
print parm_name ;                                                                                                                                                                                                                                                              
print '*** 10-parameter case ***' ;                                                                                                                                                                                                                                            
free p parm_name ;                                                                                                                                                                                                                                                             
p = 'p1' : 'p10' ;                                                                                                                                                                                                                                                              
print p ;                                                                                                                                                                                                                                                                       
do i = 1 to ncol( p ) ;                                                                                                                 
        parm_value = parentname( p[ i ] ) ;                                                                                             
        if parm_value = ' ' then parm_value = '.' ;                                                                                     
        parm_name = parm_name || parm_value ;                                                                                           
end ;                                                                                                                                                                                                                                                                           
print parm_name ;                                                                                                                                                                                                                                                              
finish ;                                                                                                                                
                                                                                                                                     
a = 1 ; b = 2 ; c = 3 ; d = 4 ; e = 5 ;f = 6 ; g = 7 ; h = 8 ; i = 9 ; j = 10 ;                                                         
                                                                                                                                        
run test( a, b, c, d, e, f, g, h, i, j ) ;                                                                                              
                                                                                                                                        
quit ;      
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output of the test() module is given below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                                                                                      *** nine-parameter case ***


                                                                                       p1 p2 p3 p4 p5 p6 p7 p8 p9


                                                                                           a b c d e f g h i


                                                                                       *** 10-parameter case ***


                                                                                p1  p2  p3  p4  p5  p6  p7  p8  p9  p10


                                                                                          . . . . . . . . . j
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the first case, all parameter names are extracted and reported correctly. In the second case, apparently the parentname() function returns a blank value which I then convert to '.' for visibility for the first nine parameters and correctly returns the name of the tenth parameter correctly.&lt;/P&gt;
&lt;P&gt;I am perplexed about this parameter passing property. Can anyone explain what is happening? Am I running into a limit on the number of IML module parameters?&lt;/P&gt;</description>
    <pubDate>Sun, 25 Dec 2022 19:35:24 GMT</pubDate>
    <dc:creator>rbettinger</dc:creator>
    <dc:date>2022-12-25T19:35:24Z</dc:date>
    <item>
      <title>IML Module Parameter Parsing Perplexities</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Module-Parameter-Parsing-Perplexities/m-p/851075#M5932</link>
      <description>&lt;P&gt;I am writing an IML module with 10 parameters defined. The first parameter is mandatory and the remaining nine are optional. I want to extract the names of numeric parameters.&lt;/P&gt;
&lt;P&gt;If I use only nine parameters, I have no trouble using the parentname() function to access a parameter and store its name.&lt;/P&gt;
&lt;P&gt;But if I use all 10 parameters, then I cannot extract the first nine and I can access only the tenth parameter.&lt;/P&gt;
&lt;P&gt;The following code defines a module with 10 parameters and two test cases: the first test case uses nine parameters and works properly. The second test case uses 10 parameters and returns a blank for the parameter name which I change to a '.' for sake of visibility. In the second case, only the name of the last parameter is returned properly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                                                                                                                                       
proc iml ;                                                                                                                              
reset noname spaces=1 ;                                                                                                                                                                                                                                                        
start test( p1, p2=, p3=, p4=, p5=, p6=, p7=, p8=, p9=, p10= ) ;                                                                                                                                                                                                   
print '*** nine-parameter case ***' ;                                                                                                                                                                                                                                        
free p parm_name ;                                                                                                                                                                                                                                                          
p = 'p1' : 'p9' ;                                                                                                                                                                                                                                                         
print p ;                                                                                                                                                                                                                                                                
do i = 1 to ncol( p ) ;                                                                                                                 
        parm_value = parentname( p[ i ] ) ;                                                                                             
        if parm_value = ' ' then parm_value = '.' ;                                                                                     
        parm_name = parm_name || parm_value ;                                                                                           
end ;                                                                                                                                                                                                                                                                          
print parm_name ;                                                                                                                                                                                                                                                              
print '*** 10-parameter case ***' ;                                                                                                                                                                                                                                            
free p parm_name ;                                                                                                                                                                                                                                                             
p = 'p1' : 'p10' ;                                                                                                                                                                                                                                                              
print p ;                                                                                                                                                                                                                                                                       
do i = 1 to ncol( p ) ;                                                                                                                 
        parm_value = parentname( p[ i ] ) ;                                                                                             
        if parm_value = ' ' then parm_value = '.' ;                                                                                     
        parm_name = parm_name || parm_value ;                                                                                           
end ;                                                                                                                                                                                                                                                                           
print parm_name ;                                                                                                                                                                                                                                                              
finish ;                                                                                                                                
                                                                                                                                     
a = 1 ; b = 2 ; c = 3 ; d = 4 ; e = 5 ;f = 6 ; g = 7 ; h = 8 ; i = 9 ; j = 10 ;                                                         
                                                                                                                                        
run test( a, b, c, d, e, f, g, h, i, j ) ;                                                                                              
                                                                                                                                        
quit ;      
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output of the test() module is given below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                                                                                      *** nine-parameter case ***


                                                                                       p1 p2 p3 p4 p5 p6 p7 p8 p9


                                                                                           a b c d e f g h i


                                                                                       *** 10-parameter case ***


                                                                                p1  p2  p3  p4  p5  p6  p7  p8  p9  p10


                                                                                          . . . . . . . . . j
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the first case, all parameter names are extracted and reported correctly. In the second case, apparently the parentname() function returns a blank value which I then convert to '.' for visibility for the first nine parameters and correctly returns the name of the tenth parameter correctly.&lt;/P&gt;
&lt;P&gt;I am perplexed about this parameter passing property. Can anyone explain what is happening? Am I running into a limit on the number of IML module parameters?&lt;/P&gt;</description>
      <pubDate>Sun, 25 Dec 2022 19:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Module-Parameter-Parsing-Perplexities/m-p/851075#M5932</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2022-12-25T19:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: IML Module Parameter Parsing Perplexities</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Module-Parameter-Parsing-Perplexities/m-p/851119#M5933</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
It is so interesting. 
You can add STRIP() as the following.

p = 'p1' : 'p10' ; 
would get these :  ' p1' ' p2' ... 'p10',
note there is a blank before p1 p2 ...p9,that would give wrong name into SAS.
Surprise ??

but if you are using p='p1':'p9' would NOT generate that problem. Surprise ??
*/ 
proc iml ;                                                                                                                              
reset noname spaces=1 ;                                                                                                                                                                                                                                                        
start test( p1, p2=, p3=, p4=, p5=, p6=, p7=, p8=, p9=, p10= ) ;                                                                                                                                                                                                   
print '*** nine-parameter case ***' ;                                                                                                                                                                                                                                        
free p parm_name ;                                                                                                                                                                                                                                                          
p = 'p1' : 'p9' ;                                                                                                                                                                                                                                                         
print p ;                                                                                                                                                                                                                                                                
do i = 1 to ncol( p ) ;                                                                                                                 
        parm_value = parentname( p[ i ] ) ;                                                                                             
        if parm_value = ' ' then parm_value = '.' ;                                                                                     
        parm_name = parm_name || parm_value ;                                                                                           
end ;                                                                                                                                                                                                                                                                          
print parm_name ;                                                                                                                                                                                                                                                              
print '*** 10-parameter case ***' ;                                                                                                                                                                                                                                            
free p parm_name ;                                                                                                                                                                                                                                                             
p = 'p1' : 'p10' ;                                                                                                                                                                                                                                                              
print p ;                                                                                                                                                                                                                                                                       
do i = 1 to ncol( p ) ;                                                                                                                 
        parm_value = parentname( strip(p[ i ]) ) ;     /*&amp;lt;--------*/                                                                                        
        if parm_value = ' ' then parm_value = '.' ;                                                                                     
        parm_name = parm_name || parm_value ;                                                                                           
end ;                                                                                                                                                                                                                                                                           
print parm_name ;                                                                                                                                                                                                                                                              
finish ;                                                                                                                                
                                                                                                                                     
a = 1 ; b = 2 ; c = 3 ; d = 4 ; e = 5 ;f = 6 ; g = 7 ; h = 8 ; i = 9 ; j = 10 ;                                                         
                                                                                                                                        
run test( a, b, c, d, e, f, g, h, i, j ) ;                                                                                              
                                                                                                                                        
quit ;    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1672050387979.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78870iB4BB9C240C038523/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1672050387979.png" alt="Ksharp_0-1672050387979.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2022 10:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Module-Parameter-Parsing-Perplexities/m-p/851119#M5933</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-12-26T10:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: IML Module Parameter Parsing Perplexities</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Module-Parameter-Parsing-Perplexities/m-p/851156#M5936</link>
      <description>The line of code 'parm_value = parentname( strip(p[ i ]) ) ;' works as Ksharp indicated, I did not read his solution carefully enough. It was very perceptive of Mr. Ksharp to understand that SAS/IML adds a blank character to pad the character literals returned by the ':' function.</description>
      <pubDate>Mon, 26 Dec 2022 19:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Module-Parameter-Parsing-Perplexities/m-p/851156#M5936</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2022-12-26T19:46:15Z</dc:date>
    </item>
  </channel>
</rss>

