<?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: double transpose issues in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/double-transpose-issues/m-p/145523#M38712</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you wand something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input CODE $ cluster_id a1 a2 a3 a4 a5;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a1 1 0 0.19516 0.19242 0.24021 0.32064&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a2 2 0.19516 0 0.22981 0.30144 0.31116&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a3 2 0.19242 0.22981 0 0.10592 0.11456&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a4 3 0.24021 0.30144 0.10592 0 0.16124&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a5 3 0.32064 0.31116 0.11456 0.16124 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc transpose data=have out=haveLong;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;by CODE cluster_id notsorted;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Add the cluster_idn matching CODE_n */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table want as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; hl.CODE, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; _name_ as CODE_n, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; hl.cluster_id, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; n.cluster_id as cluster_idn,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; COL1 as dist&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; haveLong as hl inner join &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; have as n on hl._name_=n.CODE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;order by hl.CODE, CODE_n;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 May 2014 02:00:44 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2014-05-06T02:00:44Z</dc:date>
    <item>
      <title>double transpose issues</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/double-transpose-issues/m-p/145521#M38710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all, I have a dataset which looks like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="554"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" width="71"&gt;CODE&lt;/TD&gt;&lt;TD class="xl66" style="border-left: none;" width="68"&gt;cluster_id&lt;/TD&gt;&lt;TD class="xl64" style="border-left: none;" width="102"&gt;a1&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="121"&gt;a2&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;a3&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;a4&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt;a5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;" width="71"&gt;a1&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-top: none; border-left: none;" width="68"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;" width="102"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="121"&gt;0.19516&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.19242&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.24021&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.32064&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;" width="71"&gt;a2&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-top: none; border-left: none;" width="68"&gt;2&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;" width="102"&gt;0.19516&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="121"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.22981&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.30144&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.31116&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;" width="71"&gt;a3&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-top: none; border-left: none;" width="68"&gt;2&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;" width="102"&gt;0.19242&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="121"&gt;0.22981&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.10592&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.11456&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;" width="71"&gt;a4&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-top: none; border-left: none;" width="68"&gt;3&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;" width="102"&gt;0.24021&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="121"&gt;0.30144&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.10592&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.16124&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="20" style="border-top: none;" width="71"&gt;a5&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-top: none; border-left: none;" width="68"&gt;3&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;" width="102"&gt;0.32064&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="121"&gt;0.31116&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.11456&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0.16124&lt;/TD&gt;&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to transpose this so that my final dataset looks like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="426"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" height="20" width="71"&gt;CODE&lt;/TD&gt;&lt;TD width="68"&gt;CODE_n&lt;/TD&gt;&lt;TD width="102"&gt;cluster_id&lt;/TD&gt;&lt;TD width="121"&gt;cluster_idn&lt;/TD&gt;&lt;TD width="64"&gt;dist&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;" width="71"&gt;a1&lt;/TD&gt;&lt;TD&gt;a1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl67" width="64"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;" width="71"&gt;a1&lt;/TD&gt;&lt;TD&gt;a2&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;2&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none;" width="64"&gt;0.19516&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;" width="71"&gt;a1&lt;/TD&gt;&lt;TD&gt;a3&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;2&lt;/TD&gt;&lt;TD align="right"&gt;0.19242&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="20" style="border-top: none;" width="71"&gt;a1&lt;/TD&gt;&lt;TD&gt;a4&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;3&lt;/TD&gt;&lt;TD align="right"&gt;0.32064&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and so on .....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is appreciated many thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 May 2014 21:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/double-transpose-issues/m-p/145521#M38710</guid>
      <dc:creator>hdg</dc:creator>
      <dc:date>2014-05-05T21:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: double transpose issues</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/double-transpose-issues/m-p/145522#M38711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a reason that the code_n value of a4 in your data is associated with the value of a5 in the dist variable? or should that have had a dist value of 0.24021?&lt;/P&gt;&lt;P&gt;And what is the logic for assigning cluster_idn?&lt;/P&gt;&lt;P&gt;At first glance it looks like you want to take the first row of data and create one row for each of a1 through a5 but I'm not sure your output result displayed actually matches what you want. You may want to post a few more rows of output as your other rows may need something else.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 May 2014 23:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/double-transpose-issues/m-p/145522#M38711</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-05-05T23:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: double transpose issues</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/double-transpose-issues/m-p/145523#M38712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you wand something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input CODE $ cluster_id a1 a2 a3 a4 a5;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a1 1 0 0.19516 0.19242 0.24021 0.32064&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a2 2 0.19516 0 0.22981 0.30144 0.31116&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a3 2 0.19242 0.22981 0 0.10592 0.11456&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a4 3 0.24021 0.30144 0.10592 0 0.16124&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;a5 3 0.32064 0.31116 0.11456 0.16124 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc transpose data=have out=haveLong;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;by CODE cluster_id notsorted;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Add the cluster_idn matching CODE_n */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table want as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; hl.CODE, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; _name_ as CODE_n, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; hl.cluster_id, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; n.cluster_id as cluster_idn,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; COL1 as dist&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; haveLong as hl inner join &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; have as n on hl._name_=n.CODE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;order by hl.CODE, CODE_n;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 02:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/double-transpose-issues/m-p/145523#M38712</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-05-06T02:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: double transpose issues</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/double-transpose-issues/m-p/145524#M38713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input CODE $ cluster_id a1 a2 a3 a4 a5;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;a1 1 0 0.19516 0.19242 0.24021 0.32064&lt;/P&gt;&lt;P&gt;a2 2 0.19516 0 0.22981 0.30144 0.31116&lt;/P&gt;&lt;P&gt;a3 2 0.19242 0.22981 0 0.10592 0.11456&lt;/P&gt;&lt;P&gt;a4 3 0.24021 0.30144 0.10592 0 0.16124&lt;/P&gt;&lt;P&gt;a5 3 0.32064 0.31116 0.11456 0.16124 0&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 by 1 until (last);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have end=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array temp&amp;nbsp; x1-x5 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; temp(i)=cluster_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do point=1 to nobs;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have point=point nobs=nobs;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array vars a1-a5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do i=1 to dim(vars);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain vars;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain cluster_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; code_n=vname(vars(i));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cluster_idn=temp(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dist=vars(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop x: i a:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 02:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/double-transpose-issues/m-p/145524#M38713</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2014-05-06T02:36:29Z</dc:date>
    </item>
  </channel>
</rss>

