<?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 Transposed Data with unexpected result in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transposed-Data-with-unexpected-result/m-p/505458#M135355</link>
    <description>&lt;P&gt;Hi, I have a table and i transpose it from long to wide. Since I am rushing for a flight, I havent got time to post any sample dataline data here.&lt;/P&gt;&lt;P&gt;To cut short, let me go straight to the topic with screenshots.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My table that has "long" data. Notice that 1 ID = 1 set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="countstsp data error 1.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24124i6CA48C9ABE3DE68D/image-size/large?v=v2&amp;amp;px=999" role="button" title="countstsp data error 1.PNG" alt="countstsp data error 1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And my transposed data is as below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="finalscadatransjoin error 1.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24125i9B35E639F33AEAA6/image-size/large?v=v2&amp;amp;px=999" role="button" title="finalscadatransjoin error 1.PNG" alt="finalscadatransjoin error 1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice that for newID = 25, the transposed table has 2 separate rows. However, this does not happen to newID 23 and 24. I would expect the record of newID 25 to only have 1 row, which have st_datetime and sp_datetime accordingly, not splitting into 2 different rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the command:&lt;/P&gt;&lt;PRE&gt;Final command:
proc transpose data=countstsp out=finalscadajoinedtranstable;
	by newID mnemonic_psi substationname voltagetype st_power sp_power;
	id _NAME_ ;
	var COL1 ;
	
run;&lt;/PRE&gt;&lt;P&gt;Also, before the command above, I have another command that produces similar result set(which newID 25 has 2 rows in transposed set)&lt;/P&gt;&lt;PRE&gt;proc transpose data=countstsp
out=finalscadajoinedtranstable;
	by newID mnemonic_psi substationname voltagetype ;
	id _NAME_ ;
	var COL1 ;
	copy  st_power sp_power;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which part did i do wrong? I couldn't get the logic right here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Oct 2018 08:25:02 GMT</pubDate>
    <dc:creator>WorkingMan</dc:creator>
    <dc:date>2018-10-18T08:25:02Z</dc:date>
    <item>
      <title>Transposed Data with unexpected result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposed-Data-with-unexpected-result/m-p/505458#M135355</link>
      <description>&lt;P&gt;Hi, I have a table and i transpose it from long to wide. Since I am rushing for a flight, I havent got time to post any sample dataline data here.&lt;/P&gt;&lt;P&gt;To cut short, let me go straight to the topic with screenshots.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My table that has "long" data. Notice that 1 ID = 1 set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="countstsp data error 1.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24124i6CA48C9ABE3DE68D/image-size/large?v=v2&amp;amp;px=999" role="button" title="countstsp data error 1.PNG" alt="countstsp data error 1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And my transposed data is as below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="finalscadatransjoin error 1.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24125i9B35E639F33AEAA6/image-size/large?v=v2&amp;amp;px=999" role="button" title="finalscadatransjoin error 1.PNG" alt="finalscadatransjoin error 1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice that for newID = 25, the transposed table has 2 separate rows. However, this does not happen to newID 23 and 24. I would expect the record of newID 25 to only have 1 row, which have st_datetime and sp_datetime accordingly, not splitting into 2 different rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the command:&lt;/P&gt;&lt;PRE&gt;Final command:
proc transpose data=countstsp out=finalscadajoinedtranstable;
	by newID mnemonic_psi substationname voltagetype st_power sp_power;
	id _NAME_ ;
	var COL1 ;
	
run;&lt;/PRE&gt;&lt;P&gt;Also, before the command above, I have another command that produces similar result set(which newID 25 has 2 rows in transposed set)&lt;/P&gt;&lt;PRE&gt;proc transpose data=countstsp
out=finalscadajoinedtranstable;
	by newID mnemonic_psi substationname voltagetype ;
	id _NAME_ ;
	var COL1 ;
	copy  st_power sp_power;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which part did i do wrong? I couldn't get the logic right here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 08:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposed-Data-with-unexpected-result/m-p/505458#M135355</guid>
      <dc:creator>WorkingMan</dc:creator>
      <dc:date>2018-10-18T08:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Transposed Data with unexpected result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposed-Data-with-unexpected-result/m-p/505565#M135397</link>
      <description>&lt;P&gt;Every unique combination of your BY variables generates an output line.&lt;/P&gt;
&lt;P&gt;In the shown values for Newid=23 and 24 you have no records showing values for substationname&amp;nbsp;(and the other by variables) but Newid=25 has records with both missing values and at least one value. So missing plus one substation value = 2 output records.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 14:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposed-Data-with-unexpected-result/m-p/505565#M135397</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-18T14:14:59Z</dc:date>
    </item>
  </channel>
</rss>

