<?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: Transpose, mirror/invert, calculation by row in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341895#M22628</link>
    <description>&lt;P&gt;Based on the new explanation, let's expand the problem to process a 50 x 51 data set. &amp;nbsp;Just utilize the original data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have end=done;&lt;/P&gt;
&lt;P&gt;array times {0:50} time_0 - time_50;&lt;/P&gt;
&lt;P&gt;array numers&amp;nbsp;{50} numer_1-numer_50;&lt;/P&gt;
&lt;P&gt;array denoms {50} denom_1-denom_50;&lt;/P&gt;
&lt;P&gt;do i=1 to 50;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;numers{i} + times{i};&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if times{i} &amp;gt; . then denoms{i} + times{i-1};&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;if done;&lt;/P&gt;
&lt;P&gt;length period $ 7;&lt;/P&gt;
&lt;P&gt;do i=1 to 50;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;period = cats('Time_', i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;result = numers{i} / denoms{i};&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep period result;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's untested, so there's a possibility it needs a little tweaking. &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Mar 2017 09:29:50 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-03-17T09:29:50Z</dc:date>
    <item>
      <title>Transpose, mirror/invert, calculation by row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341079#M22601</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* data have */
Period   Time_0 Time_1 Time_2 Time_3
Period_1   0       4      7      9
Period_2   1       5      8      .
Period_3   2       6      .      .
Period_4   3       .      .      .

/* transpose first */
Time     Period_1 Period_2 Period_3 Period_4
Time_0      0        1        2       3
Time_1      4        5        6       .
Time_2      7        8        .       .
Time_3      9        .        .       .

/* then mirror */
Time     Period_4 Period_3 Period_2 Period_1
Time_0      3        2        1       0
Time_1      .        6        5       4
Time_2      .        .        8       7
Time_3      .        .        .       9


/* lastly calculate */
if CountNum = 1:
Time Result
Time_1 3       /* 6/2 */
Time_2 1.6    /* 8/5 */
Time_3 1.29  /* 9/7 */

if CountNum = 2:
Time     Result
Time_1      3.67      /*  (5+6)/(1+2) */
Time_2      1.67     /* (7+8)/(4+5)  */
Time_3      1.29    /* 9/7          */

if CountNum = 3:
Time Result
Time_1 5       /* (4+5+6)/(0+1+2) */
Time_2 1.67   /* (7+8)/(4+5) */
Time_3 1.29  /* 9/7 */&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically sum up the same number (&amp;amp;CountNum) of numbers, and then it is divided by the sum of numbers from the same columns but one row above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 04:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341079#M22601</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-03-17T04:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose, mirror/invert, calculation by row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341083#M22602</link>
      <description>&lt;P&gt;Can you explain the rules more clearly, what's the logic to start off with?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 06:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341083#M22602</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-15T06:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose, mirror/invert, calculation by row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341092#M22603</link>
      <description>&lt;P&gt;Depending on the size of your data set, you may be able to fit it all into a giant two-dimensional array. &amp;nbsp;That might let you go straight to the final calculations. &amp;nbsp;However, I agree with Reeza. &amp;nbsp;The rules for that final step are very unclear.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 07:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341092#M22603</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-15T07:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose, mirror/invert, calculation by row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341230#M22610</link>
      <description>&lt;P&gt;And the purpose of this set&amp;nbsp;is what exactly:&lt;/P&gt;
&lt;PRE&gt;/* then mirror */
Time     Period_4 Period_3 Period_2 Period_1
Time_0      1        1        1       1
Time_1      .        2        2       2
Time_2      .        .        3       3
Time_3      .        .        .       4


&lt;/PRE&gt;
&lt;P&gt;Anything I can calculate from this in SAS I can calculate from the previous data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you replicating some process developed from Excel???? Generally not the best model for manipulation in SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 15:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341230#M22610</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-15T15:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose, mirror/invert, calculation by row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341859#M22625</link>
      <description>&lt;P&gt;Have edited the post. Hopefully the new dataset would be able to demonstrate what has been done in each process.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 04:39:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341859#M22625</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-03-17T04:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose, mirror/invert, calculation by row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341895#M22628</link>
      <description>&lt;P&gt;Based on the new explanation, let's expand the problem to process a 50 x 51 data set. &amp;nbsp;Just utilize the original data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have end=done;&lt;/P&gt;
&lt;P&gt;array times {0:50} time_0 - time_50;&lt;/P&gt;
&lt;P&gt;array numers&amp;nbsp;{50} numer_1-numer_50;&lt;/P&gt;
&lt;P&gt;array denoms {50} denom_1-denom_50;&lt;/P&gt;
&lt;P&gt;do i=1 to 50;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;numers{i} + times{i};&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if times{i} &amp;gt; . then denoms{i} + times{i-1};&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;if done;&lt;/P&gt;
&lt;P&gt;length period $ 7;&lt;/P&gt;
&lt;P&gt;do i=1 to 50;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;period = cats('Time_', i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;result = numers{i} / denoms{i};&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;keep period result;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's untested, so there's a possibility it needs a little tweaking. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 09:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/341895#M22628</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-17T09:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose, mirror/invert, calculation by row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/342422#M22664</link>
      <description>Hi Astounding, thanks for your post. Could you please briefly explain what each line means in your code?&lt;BR /&gt;&lt;BR /&gt;Also, how about using multidimensional arrays?</description>
      <pubDate>Sun, 19 Mar 2017 23:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/342422#M22664</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-03-19T23:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose, mirror/invert, calculation by row</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/342535#M22678</link>
      <description>&lt;P&gt;I can give you the big picture. &amp;nbsp;But you have to be responsible for knowing basic SAS statements like a DATA statement, a SET statement, END= option, subsetting IF, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The arrays define sets of variables. &amp;nbsp;The problem could be done without using arrays, but the amount of code would become excessive. &amp;nbsp;Arrays let you apply a DO loop, processing each variable in the array, with minimal programming.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NUMER_1 will be the sum of all TIME_1 values, NUMER_2 the sum of all TIME_2 values, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DENOM_1 will be the sum of most TIME_0 values, DENOM_2 the sum of most TIME_1 values, etc. &amp;nbsp;"Most" means that the NUMER variable has to be nonmissing in order to include the value in the DENOM. &amp;nbsp;For example, DENOM_1 is the sum of all the TIME_0 values where TIME_1 is nonmissing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once all those sums have been calculated. perform the final division and output each as a separate observation.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 11:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Transpose-mirror-invert-calculation-by-row/m-p/342535#M22678</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-20T11:29:02Z</dc:date>
    </item>
  </channel>
</rss>

