<?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: Proc Transpose output help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334084#M75397</link>
    <description>Thanks Art. This works.&lt;BR /&gt;&lt;BR /&gt;Can you please help me understand this. Still a learner.&lt;BR /&gt;&lt;BR /&gt;x=_x(time);&lt;BR /&gt;y=_y(time);&lt;BR /&gt;&lt;BR /&gt;What does _x and _y do?&lt;BR /&gt;</description>
    <pubDate>Sat, 18 Feb 2017 15:49:13 GMT</pubDate>
    <dc:creator>adityaa9z</dc:creator>
    <dc:date>2017-02-18T15:49:13Z</dc:date>
    <item>
      <title>Proc Transpose output help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334070#M75390</link>
      <description>&lt;P&gt;Below is the DS "wide".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data wide;&lt;BR /&gt;input subj$ x1 x2 x3 x4 x5 y1 y2 y3 y4 y5;&lt;BR /&gt;cards;&lt;BR /&gt;001 8 5 6 5 4 10 20 30 40 50&lt;BR /&gt;002 7 5 6 4 5 11 33 29 34 56&lt;BR /&gt;003 2 2 4 5 6 22 38 21 20 34&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need output using proc transpose. First 10 obs of LONG DB should look like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subj Time X Y&lt;/P&gt;&lt;P&gt;001 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp;8 10&lt;/P&gt;&lt;P&gt;001 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;5 20&lt;/P&gt;&lt;P&gt;001 &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp;6 30&lt;/P&gt;&lt;P&gt;001 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp;5 40 &amp;nbsp;&lt;/P&gt;&lt;P&gt;001 &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp;4 50&lt;/P&gt;&lt;P&gt;002 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp;7 11&lt;/P&gt;&lt;P&gt;002 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp;5 33&lt;/P&gt;&lt;P&gt;002 &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp;6 29&lt;/P&gt;&lt;P&gt;002 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp;4 34&lt;/P&gt;&lt;P&gt;002 &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp;5 56&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 15:14:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334070#M75390</guid>
      <dc:creator>adityaa9z</dc:creator>
      <dc:date>2017-02-18T15:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose output help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334078#M75394</link>
      <description>&lt;P&gt;Why do you NEED to use proc transpose? The problem is solved more easily with a data step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want (keep=subj time x y);
  set wide;
  array _x x1-x5;
  array _y y1-y5;
  do time=1 to 5;
    x=_x(time);
    y=_y(time);
    output;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 15:31:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334078#M75394</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-18T15:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose output help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334084#M75397</link>
      <description>Thanks Art. This works.&lt;BR /&gt;&lt;BR /&gt;Can you please help me understand this. Still a learner.&lt;BR /&gt;&lt;BR /&gt;x=_x(time);&lt;BR /&gt;y=_y(time);&lt;BR /&gt;&lt;BR /&gt;What does _x and _y do?&lt;BR /&gt;</description>
      <pubDate>Sat, 18 Feb 2017 15:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334084#M75397</guid>
      <dc:creator>adityaa9z</dc:creator>
      <dc:date>2017-02-18T15:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose output help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334088#M75401</link>
      <description>&lt;P&gt;If you look at the code:&lt;/P&gt;
&lt;PRE&gt;data want (keep=subj time x y);
  set wide;
  array _x x1-x5;
  array _y y1-y5;
  do time=1 to 5;
    x=_x(time);
    y=_y(time);
    output;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;_x is the name assigned to an array that will contain the five values of x1 thru x5&lt;/P&gt;
&lt;P&gt;_y is the name assigned to an array that will contain the five values of y1 thru y5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a do loop is then used to create the variable TIME and, within the loop, the values of x and y are assigned the values contained in the 1st thru fifth elements of the two arrays.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, here is how you could do the same thing using proc transpose (but using more code):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc transpose data=wide out=needx (rename=(_name_=_time col1=x));
  var x1--x5;
  by subj;
run;

proc transpose data=wide out=needy (rename=(_name_=_time col1=y));
  var y1--y5;
  by subj;
run;

data want (drop=_:);
  set needx;
  set needy;
  time=input(compress(_time,'y'),8.);
run;

data want;
  retain subj time x y;
  set want2;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 15:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334088#M75401</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-18T15:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose output help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334189#M75455</link>
      <description>&lt;P&gt;Hi art297,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to ask you a small question about the code please.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see that the variable "subj" isn't included in the loop, but nonetheless each subj is repeated 5 times - so that means that when you set the data "wide", the subsequent loop is applied to each observation of the original data "wide", as if there is a loop within a loop?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 19 Feb 2017 16:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334189#M75455</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2017-02-19T16:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose output help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334190#M75456</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12982"&gt;@ilikesas&lt;/a&gt;: subj, x1, x2, x3, x4, x5, y1, y2, y3, y4, and y5 were all populated by the set statement and would have been present in the output file, but I excluded them by including a keep option in the file declared by the data statement.&lt;/P&gt;
&lt;P&gt;The do loop was accomplished within each iteration. Thus, yes, it is like a loop within a loop because the normal datastep is, in fact, a loop where _n_ defines which iteration (record) the code is working on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sun, 19 Feb 2017 16:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Transpose-output-help/m-p/334190#M75456</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-19T16:50:26Z</dc:date>
    </item>
  </channel>
</rss>

