<?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? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/814816#M321630</link>
    <description>&lt;P&gt;This looks more like a report than a useful dataset structure. What do you intend to do with the result?&lt;/P&gt;</description>
    <pubDate>Tue, 24 May 2022 04:39:21 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-05-24T04:39:21Z</dc:date>
    <item>
      <title>Proc transpose?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/814808#M321629</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi, hoping to get some help to get from this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data have;&lt;BR /&gt;input ID Type $ Cost AppleValue OrangeValue;&lt;BR /&gt;infile datalines missover;&lt;BR /&gt;datalines;&lt;BR /&gt;1 Apple 810 1 .&lt;BR /&gt;1 Orange 2000 . 3&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To this is what I need:&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 265pt;" border="0" width="350" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 13.8pt;"&gt;
&lt;TD width="70" height="18" style="height: 13.8pt; width: 53pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="70" style="width: 53pt;"&gt;Count_Apple&lt;/TD&gt;
&lt;TD width="70" style="width: 53pt;"&gt;Count_Orange&lt;/TD&gt;
&lt;TD width="70" style="width: 53pt;"&gt;AppleValueA&lt;/TD&gt;
&lt;TD width="70" style="width: 53pt;"&gt;OrangeValueA&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 13.8pt;"&gt;
&lt;TD height="18" align="right" style="height: 13.8pt;"&gt;1&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;810&lt;/TD&gt;
&lt;TD align="right"&gt;2000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 00:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/814808#M321629</guid>
      <dc:creator>ywon111</dc:creator>
      <dc:date>2022-05-24T00:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/814816#M321630</link>
      <description>&lt;P&gt;This looks more like a report than a useful dataset structure. What do you intend to do with the result?&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 04:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/814816#M321630</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-24T04:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/814882#M321654</link>
      <description>&lt;P&gt;Does your real data have the data only on the diagonal like that?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input ID Type $ Cost Apple Orange Pear Zucchini ;
datalines;
1 Apple      810 1 . . .
1 Orange    2000 . 3 . .
1 Pear       300 . . 4 .
1 Zucchini   400 . . . 5
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or are some of the off diagonal cells non-missing? If so where are those values supposed to end up in the target dataset?&lt;/P&gt;
&lt;P&gt;So perhaps you should first make the data taller and then transpose it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data for_transpose;
  set have;
  by id ;
  row+first.id;
  length var $32 ;
  var = cats('Count',type);
  value = max(of apple -- zucchini);
  output;
  var = cats(type,'Value');
  value = cost;
  output;
run;

proc transpose data=for_transpose out=want;
  by id ;
  id var row;
  var value;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1653402901137.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71738iF84D6768FBE401AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1653402901137.png" alt="Tom_0-1653402901137.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 14:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/814882#M321654</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-24T14:35:14Z</dc:date>
    </item>
  </channel>
</rss>

