<?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: Array Issue.. Need Help in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44078#M11615</link>
    <description>Hi Cynthia, &lt;BR /&gt;
&lt;BR /&gt;
Thanks for a detailed reply, was extremely helpful. &lt;BR /&gt;
I know it just looks from the code that I pasted that all I am doing is trying to format the variable, however there is a lot more to it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
My broader objective was to build a dynamic code and more importantly dynamic array. The only place I was stuck was that I have used arrays to take values from different variables, but I wanted to build an array which can take different values of single variable. I had used a Proc Select into: statement to have the values depicted into a single macro variable &amp;amp;acct. and then Scott helped me in using that to build a dynamic array. &lt;BR /&gt;
&lt;BR /&gt;
Once the above was done, I noticed that my input values were of 16byte however the actual output showed me a value like 60493E45. and hence I just added "FORMAT _ALL_ 16. to the loop, and havent actually pasted the rest of it.&lt;BR /&gt;
&lt;BR /&gt;
But thanks for sending a detailed information, it really helps a lot, since I am also relatively new to SAS.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Tejeshwar</description>
    <pubDate>Mon, 15 Jun 2009 17:22:54 GMT</pubDate>
    <dc:creator>tejeshwar</dc:creator>
    <dc:date>2009-06-15T17:22:54Z</dc:date>
    <item>
      <title>Array Issue.. Need Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44070#M11607</link>
      <description>Hi, &lt;BR /&gt;
&lt;BR /&gt;
I ran into a weird issue with Arrays this morning. &lt;BR /&gt;
If I run this, it works perfectly fine. I dont want to define the number of elements in the array&lt;BR /&gt;
ARRAY accttant {*} xs as is rs ds;&lt;BR /&gt;
&lt;BR /&gt;
however it gives me the error while running this&lt;BR /&gt;
&lt;BR /&gt;
ARRAY accttantt {*} 123 211 234;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: The array accttantt has been defined with zero elements.&lt;BR /&gt;
ERROR 352-185: The length of numeric variables is 3-8.&lt;BR /&gt;
&lt;BR /&gt;
ERROR 22-322: Syntax error, expecting one of the following: a name, (, ;, _ALL_, _CHARACTER_,&lt;BR /&gt;
              _CHAR_, _NUMERIC_, _TEMPORARY_.&lt;BR /&gt;
&lt;BR /&gt;
ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;
&lt;BR /&gt;
Please help.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Tejeshwar</description>
      <pubDate>Fri, 12 Jun 2009 14:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44070#M11607</guid>
      <dc:creator>tejeshwar</dc:creator>
      <dc:date>2009-06-12T14:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Array Issue.. Need Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44071#M11608</link>
      <description>SAS variable names must start with an alpha character.  Also, consider using parentheses instead of brackets, unless you prefer the uniqueness of brackets when reading array-related code (strictly cosmetic - nothing more).&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 12 Jun 2009 14:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44071#M11608</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-12T14:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Array Issue.. Need Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44072#M11609</link>
      <description>Hi, &lt;BR /&gt;
&lt;BR /&gt;
I am trying to input values to the array, and not variable names. &lt;BR /&gt;
For ex: If I define the number of elements in the array, the same syntax works perfectly.&lt;BR /&gt;
For ex: &lt;BR /&gt;
data d;&lt;BR /&gt;
ARRAY accttanttt {3}  (123 321 234);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Remote submit to SERVER commencing.&lt;BR /&gt;
32   data d;&lt;BR /&gt;
33   ARRAY accttanttt {3}  (123 321 234);&lt;BR /&gt;
34   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The data set WORK.D has 1 observations and 3 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
Here is the print of that dataset&lt;BR /&gt;
&lt;BR /&gt;
Obs    accttanttt1    accttanttt2    accttanttt3&lt;BR /&gt;
&lt;BR /&gt;
                          1         123            321        234&lt;BR /&gt;
&lt;BR /&gt;
I am confused as to why it doesnt works when we dont define the array elements.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Tejeshwar</description>
      <pubDate>Fri, 12 Jun 2009 14:58:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44072#M11609</guid>
      <dc:creator>tejeshwar</dc:creator>
      <dc:date>2009-06-12T14:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Array Issue.. Need Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44073#M11610</link>
      <description>The two sceanarios you describe are very different, so why would you expect the behavior to be consistent (round hole, square peg)?  &lt;BR /&gt;
&lt;BR /&gt;
Reading the DOC, you need to declare some array content attribute - here is one approach to consider:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%let x_vals = 1 2 3 4 5;&lt;BR /&gt;
* incoming array data values known, now use them in the DATA step. ;&lt;BR /&gt;
data x;&lt;BR /&gt;
array x ( %sysfunc(countw(&amp;amp;x_vals)) ) _temporary_ (&amp;amp;x_vals);&lt;BR /&gt;
do i=1 to dim(x);&lt;BR /&gt;
  putlog x(i)= ;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 12 Jun 2009 15:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44073#M11610</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-12T15:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Array Issue.. Need Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44074#M11611</link>
      <description>Thanks Scott.&lt;BR /&gt;
This worked the way I want it to work. I have one more question that I am troubling you with. My actual data values are of length 16, however while producing the output SAS displays it like 6.7392E15&lt;BR /&gt;
I tried to define the length while defining the array, but it throws me an error &lt;BR /&gt;
&lt;BR /&gt;
ERROR 352-185: The length of numeric variables is 3-8.&lt;BR /&gt;
&lt;BR /&gt;
Will there be a way around this?&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Tejeshwar</description>
      <pubDate>Fri, 12 Jun 2009 16:21:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44074#M11611</guid>
      <dc:creator>tejeshwar</dc:creator>
      <dc:date>2009-06-12T16:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Array Issue.. Need Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44075#M11612</link>
      <description>The SAS LENGTH and FORMAT attributes are quite different.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS 9.2 Language Ref: Dictionary, Formats&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000309859.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000309859.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
SAS 9.2 Language Concepts - SAS Variables&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000998827.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000998827.htm&lt;/A&gt;</description>
      <pubDate>Fri, 12 Jun 2009 16:32:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44075#M11612</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-12T16:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Array Issue.. Need Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44076#M11613</link>
      <description>Thanks Scott.&lt;BR /&gt;
I used the below to generate what i needed, the format is also resolved now &lt;BR /&gt;
&lt;BR /&gt;
data x;&lt;BR /&gt;
array ab ( %sysfunc(countw(&amp;amp;acct)) ) (&amp;amp;acct);&lt;BR /&gt;
do i=1 to dim(ab);&lt;BR /&gt;
format _ALL_ 16.;&lt;BR /&gt;
end;&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 12 Jun 2009 17:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44076#M11613</guid>
      <dc:creator>tejeshwar</dc:creator>
      <dc:date>2009-06-12T17:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Array Issue.. Need Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44077#M11614</link>
      <description>Hi:&lt;BR /&gt;
  If all you wanted to do was FORMAT the numbers, you did not need an array at all. You could have used &lt;BR /&gt;
[pre]&lt;BR /&gt;
format _ALL_ 16.;&lt;BR /&gt;
OR&lt;BR /&gt;
format _NUMERIC_ 16.;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
in your DATA step program, without any ARRAY processing.&lt;BR /&gt;
&lt;BR /&gt;
Certain statements in SAS are considered "compile time statements", as described here in the doc:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a001225397.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a001225397.htm&lt;/A&gt; &lt;BR /&gt;
  &lt;BR /&gt;
The documentation makes the distinction between "executable" statements and "declarative" statements, but also says that "declarative" statements "take effect when the system compiles program statements"&lt;BR /&gt;
&lt;BR /&gt;
This paper is a good introduction to how the DATA step operates:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi29/252-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/252-29.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
And this is specific documentation on the FORMAT statement:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000178212.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000178212.htm&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
So, the FORMAT statement only gets used at compile time. Therefore, your do loop was not required, if all you wanted to do was apply the format to _ALL_ the variables (assuming that all the variables were numeric). Additionally, you could have used _NUMERIC_ to apply the 16. format to all the numeric variables in the data set.&lt;BR /&gt;
 &lt;BR /&gt;
You can test out the behavior of the FORMAT statement WITHOUT a do loop by running the program below. It shows both _ALL_ and _NUMERIC_. And, of course, the best place to set the format for your variables is when you are reading them into SAS data set format, if possible. I could have put the FORMAT statement in the program with the INFILE/INPUT statements. That way, I would ensure that my desired formats (and/or labels) were already in place the first time I went to use the data set.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data testfmt;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input x y z;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
6712345678901234 7821346573704321 5532652376996357&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
             &lt;BR /&gt;
proc print data=testfmt;&lt;BR /&gt;
  title 'proc print with no formats';&lt;BR /&gt;
run;&lt;BR /&gt;
    &lt;BR /&gt;
** set format WITHOUT array (assumes all variables are numeric);&lt;BR /&gt;
data withfmt;&lt;BR /&gt;
  set testfmt;&lt;BR /&gt;
  format _all_ 16.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=withfmt;&lt;BR /&gt;
  title 'New Data Set With Formats';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc contents data=withfmt;&lt;BR /&gt;
  title 'What is in Descriptor Portion of Data Set?';&lt;BR /&gt;
run;&lt;BR /&gt;
 &lt;BR /&gt;
** what if data set has both character and numeric vars;&lt;BR /&gt;
data withchar;&lt;BR /&gt;
  set testfmt;&lt;BR /&gt;
  longword = 'supercalifragilisticexpealidocious';&lt;BR /&gt;
  format _numeric_ 16. _character_ $34.&lt;BR /&gt;
run;&lt;BR /&gt;
           &lt;BR /&gt;
proc print data=withchar;&lt;BR /&gt;
  title 'New Data Set With Character Variable';&lt;BR /&gt;
run;&lt;BR /&gt;
          &lt;BR /&gt;
proc contents data=withchar;&lt;BR /&gt;
  title 'What is in Descriptor Portion of Data Set?';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Sat, 13 Jun 2009 20:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44077#M11614</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-06-13T20:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Array Issue.. Need Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44078#M11615</link>
      <description>Hi Cynthia, &lt;BR /&gt;
&lt;BR /&gt;
Thanks for a detailed reply, was extremely helpful. &lt;BR /&gt;
I know it just looks from the code that I pasted that all I am doing is trying to format the variable, however there is a lot more to it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
My broader objective was to build a dynamic code and more importantly dynamic array. The only place I was stuck was that I have used arrays to take values from different variables, but I wanted to build an array which can take different values of single variable. I had used a Proc Select into: statement to have the values depicted into a single macro variable &amp;amp;acct. and then Scott helped me in using that to build a dynamic array. &lt;BR /&gt;
&lt;BR /&gt;
Once the above was done, I noticed that my input values were of 16byte however the actual output showed me a value like 60493E45. and hence I just added "FORMAT _ALL_ 16. to the loop, and havent actually pasted the rest of it.&lt;BR /&gt;
&lt;BR /&gt;
But thanks for sending a detailed information, it really helps a lot, since I am also relatively new to SAS.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Tejeshwar</description>
      <pubDate>Mon, 15 Jun 2009 17:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-Issue-Need-Help/m-p/44078#M11615</guid>
      <dc:creator>tejeshwar</dc:creator>
      <dc:date>2009-06-15T17:22:54Z</dc:date>
    </item>
  </channel>
</rss>

