<?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 SAS array in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SAS-array/m-p/49049#M13301</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I run into something interesting. I have a data set as&lt;BR /&gt;
qid             a             b               c&lt;BR /&gt;
DP005205	0.49	-2	0.019&lt;BR /&gt;
DP005206	0.934	-1.793	0.095&lt;BR /&gt;
DP005207	0.888	-0.073	0.024.&lt;BR /&gt;
&lt;BR /&gt;
Then in order to use them in another data set, I put the three records into one record data set as&lt;BR /&gt;
qqid1 qqid2 qqid3 a1 a2 a3 b1 b2 b3 c1 c2 c3&lt;BR /&gt;
DP005205	DP005206	DP005207	0.49 0.934	0.888 -2 -1.793 -0.073	0.019 0.095 0.024&lt;BR /&gt;
&lt;BR /&gt;
In the third data set, I retrieved the one record and tried to put the data in four arrays as qid, a, b, and c and output the result to log to check if the data were correctly retrieved. Following is the related piece of code&lt;BR /&gt;
if _N_ = 1 then do;&lt;BR /&gt;
    set itemarr;&lt;BR /&gt;
    retain qqid1-qqid%left(&amp;amp;itemno.) a1-a%left(&amp;amp;itemno.) b1-b%left(&amp;amp;itemno.) c1-c%left(&amp;amp;itemno.);&lt;BR /&gt;
    array qqid (*) qqid1-qqid%left(&amp;amp;itemno.);&lt;BR /&gt;
    array a (*) a1-a%left(&amp;amp;itemno.);&lt;BR /&gt;
    array b (*) b1-b%left(&amp;amp;itemno.);&lt;BR /&gt;
    array c (*) c1-c%left(&amp;amp;itemno.);&lt;BR /&gt;
   do i = 1 to &amp;amp;itemno.;&lt;BR /&gt;
       if qqid(i) ne '' then put qqid(i) a(i) b(i) c(i);&lt;BR /&gt;
   end;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
The macro variable &amp;amp;itemno.=3 here. But the log shows the retrieved result with two incorrect b values -2 and -0 as &lt;BR /&gt;
qid             a     b   c&lt;BR /&gt;
DP005205 0.49 -2 0.019&lt;BR /&gt;
DP005206 0.934 -2 0.095&lt;BR /&gt;
DP005207 0.888 -0 0.024&lt;BR /&gt;
&lt;BR /&gt;
It seems the problem is associated with rounding. But why only these two values cannot be retrieved correctly? &lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Ming</description>
    <pubDate>Thu, 25 Jun 2009 19:24:44 GMT</pubDate>
    <dc:creator>mlei_collegeboard_org</dc:creator>
    <dc:date>2009-06-25T19:24:44Z</dc:date>
    <item>
      <title>SAS array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-array/m-p/49049#M13301</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I run into something interesting. I have a data set as&lt;BR /&gt;
qid             a             b               c&lt;BR /&gt;
DP005205	0.49	-2	0.019&lt;BR /&gt;
DP005206	0.934	-1.793	0.095&lt;BR /&gt;
DP005207	0.888	-0.073	0.024.&lt;BR /&gt;
&lt;BR /&gt;
Then in order to use them in another data set, I put the three records into one record data set as&lt;BR /&gt;
qqid1 qqid2 qqid3 a1 a2 a3 b1 b2 b3 c1 c2 c3&lt;BR /&gt;
DP005205	DP005206	DP005207	0.49 0.934	0.888 -2 -1.793 -0.073	0.019 0.095 0.024&lt;BR /&gt;
&lt;BR /&gt;
In the third data set, I retrieved the one record and tried to put the data in four arrays as qid, a, b, and c and output the result to log to check if the data were correctly retrieved. Following is the related piece of code&lt;BR /&gt;
if _N_ = 1 then do;&lt;BR /&gt;
    set itemarr;&lt;BR /&gt;
    retain qqid1-qqid%left(&amp;amp;itemno.) a1-a%left(&amp;amp;itemno.) b1-b%left(&amp;amp;itemno.) c1-c%left(&amp;amp;itemno.);&lt;BR /&gt;
    array qqid (*) qqid1-qqid%left(&amp;amp;itemno.);&lt;BR /&gt;
    array a (*) a1-a%left(&amp;amp;itemno.);&lt;BR /&gt;
    array b (*) b1-b%left(&amp;amp;itemno.);&lt;BR /&gt;
    array c (*) c1-c%left(&amp;amp;itemno.);&lt;BR /&gt;
   do i = 1 to &amp;amp;itemno.;&lt;BR /&gt;
       if qqid(i) ne '' then put qqid(i) a(i) b(i) c(i);&lt;BR /&gt;
   end;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
The macro variable &amp;amp;itemno.=3 here. But the log shows the retrieved result with two incorrect b values -2 and -0 as &lt;BR /&gt;
qid             a     b   c&lt;BR /&gt;
DP005205 0.49 -2 0.019&lt;BR /&gt;
DP005206 0.934 -2 0.095&lt;BR /&gt;
DP005207 0.888 -0 0.024&lt;BR /&gt;
&lt;BR /&gt;
It seems the problem is associated with rounding. But why only these two values cannot be retrieved correctly? &lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Ming</description>
      <pubDate>Thu, 25 Jun 2009 19:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-array/m-p/49049#M13301</guid>
      <dc:creator>mlei_collegeboard_org</dc:creator>
      <dc:date>2009-06-25T19:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-array/m-p/49050#M13302</link>
      <description>I executed your code as documented, and I do not get the problem - the b1-b3 variables are accurate.&lt;BR /&gt;
&lt;BR /&gt;
You would benefit from adding some PUTLOG _ALL_; commands in your code to monitor each data step pass.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 25 Jun 2009 19:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-array/m-p/49050#M13302</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-25T19:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-array/m-p/49051#M13303</link>
      <description>I restarted my SAS and still got the same problem. Did you use SAS version 9? I got the problem solved by adding in the following code before the set statement. But I still don't know why.&lt;BR /&gt;
&lt;BR /&gt;
informat b 6.3;&lt;BR /&gt;
format b 6.3;&lt;BR /&gt;
&lt;BR /&gt;
Thanks!!&lt;BR /&gt;
Ming</description>
      <pubDate>Thu, 25 Jun 2009 20:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-array/m-p/49051#M13303</guid>
      <dc:creator>mlei_collegeboard_org</dc:creator>
      <dc:date>2009-06-25T20:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS array</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-array/m-p/49052#M13304</link>
      <description>I don't see how - SAS-standard formats truncate normally.  SAS 9.1.3 SP4 system - both Windows and IBM z/OS (mainframe) flavors.  You must have some other code influencing the outcome of your un-transposed output which is not revealed in what you posted, other than the final variable values.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 25 Jun 2009 21:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-array/m-p/49052#M13304</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-25T21:41:49Z</dc:date>
    </item>
  </channel>
</rss>

