<?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 Array Error ? Var_Char = put(Var_Num,3)? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860492#M339927</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have error messages shown in the log window when I try to do an array.&amp;nbsp; Please help; thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds2;
set ds1;
array Var_Num{i} hcsfpcrothresult  rapidrsvothersp ;                                    
array Var_Cha{i} hcsfpcroth_result  rapidrsvother_sp ;                                      
 do i = 1 to dim(Var_Cha);                                      
	  Var_Num{i}=put(Var_Cha{i}, 3.); 
drop Var_Num{i}; 
 end;  

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;1883  array Var_Num{i} hcsfpcrothresult  rapidrsvothersp ;
                    -
                    22
                    202
ERROR: Too many variables defined for the dimension(s) specified for the array Var_Num.
1884  array Var_Cha{i} hcsfpcroth_result  rapidrsvother_sp ;
                    -
                    22
                    202
ERROR: Too many variables defined for the dimension(s) specified for the array Var_Cha.
ERROR 22-322: Syntax error, expecting one of the following: an integer constant, *.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

1885   do i = 1 to dim(Var_Cha);
1886        Var_Num{i}=put(Var_Cha{i}, 3.);
1887  drop Var_Num{i};
                  -
                  22
                  76
ERROR 22-322: Syntax error, expecting one of the following: a name, -, :, ;, _ALL_, _CHARACTER_,
              _CHAR_, _NUMERIC_.

ERROR 76-322: Syntax error, statement will be ignored.

1888   end;
&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
    <pubDate>Thu, 23 Feb 2023 16:53:05 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2023-02-23T16:53:05Z</dc:date>
    <item>
      <title>Array Error ? Var_Char = put(Var_Num,3)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860492#M339927</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have error messages shown in the log window when I try to do an array.&amp;nbsp; Please help; thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds2;
set ds1;
array Var_Num{i} hcsfpcrothresult  rapidrsvothersp ;                                    
array Var_Cha{i} hcsfpcroth_result  rapidrsvother_sp ;                                      
 do i = 1 to dim(Var_Cha);                                      
	  Var_Num{i}=put(Var_Cha{i}, 3.); 
drop Var_Num{i}; 
 end;  

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;1883  array Var_Num{i} hcsfpcrothresult  rapidrsvothersp ;
                    -
                    22
                    202
ERROR: Too many variables defined for the dimension(s) specified for the array Var_Num.
1884  array Var_Cha{i} hcsfpcroth_result  rapidrsvother_sp ;
                    -
                    22
                    202
ERROR: Too many variables defined for the dimension(s) specified for the array Var_Cha.
ERROR 22-322: Syntax error, expecting one of the following: an integer constant, *.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

1885   do i = 1 to dim(Var_Cha);
1886        Var_Num{i}=put(Var_Cha{i}, 3.);
1887  drop Var_Num{i};
                  -
                  22
                  76
ERROR 22-322: Syntax error, expecting one of the following: a name, -, :, ;, _ALL_, _CHARACTER_,
              _CHAR_, _NUMERIC_.

ERROR 76-322: Syntax error, statement will be ignored.

1888   end;
&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Thu, 23 Feb 2023 16:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860492#M339927</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2023-02-23T16:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Array Error ? Var_Char = put(Var_Num,3)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860494#M339928</link>
      <description>&lt;P&gt;I think it is good advice for you to show us the ENTIRE log for this DATA step, not the portion you did show us.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In ARRAY statements, you put the number of elements inside the curly brackets, not a variable name like you did.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 16:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860494#M339928</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-23T16:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Array Error ? Var_Char = put(Var_Num,3)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860496#M339929</link>
      <description>&lt;P&gt;The log tells you the array declarations are wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds2;
set ds1;
array Var_Num(2) hcsfpcrothresult  rapidrsvothersp ;                                    
array Var_Cha{2) hcsfpcroth_result  rapidrsvother_sp ;                                      
 do i = 1 to dim(Var_Cha);                                      
	  Var_Num{i}=put(Var_Cha{i}, 3.); 
 end;  

drop hcsfpcrothresult  rapidrsvothersp ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's a tutorial on using Arrays in SAS&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have error messages shown in the log window when I try to do an array.&amp;nbsp; Please help; thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds2;
set ds1;
array Var_Num{i} hcsfpcrothresult  rapidrsvothersp ;                                    
array Var_Cha{i} hcsfpcroth_result  rapidrsvother_sp ;                                      
 do i = 1 to dim(Var_Cha);                                      
	  Var_Num{i}=put(Var_Cha{i}, 3.); 
drop Var_Num{i}; 
 end;  

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;1883  array Var_Num{i} hcsfpcrothresult  rapidrsvothersp ;
                    -
                    22
                    202
ERROR: Too many variables defined for the dimension(s) specified for the array Var_Num.
1884  array Var_Cha{i} hcsfpcroth_result  rapidrsvother_sp ;
                    -
                    22
                    202
ERROR: Too many variables defined for the dimension(s) specified for the array Var_Cha.
ERROR 22-322: Syntax error, expecting one of the following: an integer constant, *.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

1885   do i = 1 to dim(Var_Cha);
1886        Var_Num{i}=put(Var_Cha{i}, 3.);
1887  drop Var_Num{i};
                  -
                  22
                  76
ERROR 22-322: Syntax error, expecting one of the following: a name, -, :, ;, _ALL_, _CHARACTER_,
              _CHAR_, _NUMERIC_.

ERROR 76-322: Syntax error, statement will be ignored.

1888   end;
&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 17:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860496#M339929</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-02-23T17:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Array Error ? Var_Char = put(Var_Num,3)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860500#M339931</link>
      <description>&lt;P&gt;You are not defining the array properly.&amp;nbsp; You don't have to tell SAS how many variables are in the array when you have listed the variables explicitly. SAS can count.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array Var_Num  hcsfpcrothresult  rapidrsvothersp ;
array Var_Cha hcsfpcroth_result  rapidrsvother_sp ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want you can waste your time and specify the dimension then use either the actual dimension or a *.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array Var_Num [*] hcsfpcrothresult  rapidrsvothersp ;
array Var_Cha [2] hcsfpcroth_result  rapidrsvother_sp ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You cannot drop an array. Only the actual variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;drop hcsfpcrothresult  rapidrsvothersp ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: If you want to list a variable in the dimension of the array definition then you have to use regular parentheses instead of either square or curly brackets.&amp;nbsp; But then you are defining an array that must index implicitly instead of explicitly since the variable name you put is the name of the variable that will be used to index the array&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds2;
  set ds1;
  array Var_Num (i) hcsfpcrothresult  rapidrsvothersp ;
  array Var_Cha (i) hcsfpcroth_result  rapidrsvother_sp ;
  do i = 1 to dim(Var_Cha);                                      
     Var_Num=put(Var_Cha, 3.); 
  end;  
  drop hcsfpcrothresult  rapidrsvothersp ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Feb 2023 17:16:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860500#M339931</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-23T17:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: Array Error ? Var_Char = put(Var_Num,3)?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860508#M339937</link>
      <description>&lt;P&gt;Create a value and then attempt to drop it?&lt;/P&gt;
&lt;P&gt;Put a value, which creates character values, into what appears is intended to be numeric value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe describe what you intended to do, i.e. provide example values and the output.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 17:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Error-Var-Char-put-Var-Num-3/m-p/860508#M339937</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-23T17:59:15Z</dc:date>
    </item>
  </channel>
</rss>

