<?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: Data Transpose/Pivot in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430237#M281580</link>
    <description>&lt;P&gt;Thanks for the response ballardw.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess my Excel roots are showing up. Hehe.&lt;/P&gt;&lt;P&gt;To answer your question, I actually just need the last column to show up (the "percent" variable). All box values will be dropped.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case though, Reeza was able to provide a solution a few minutes ago. Still, I appreciate your support. Have a great day ahead!&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jan 2018 00:58:53 GMT</pubDate>
    <dc:creator>Tony5</dc:creator>
    <dc:date>2018-01-24T00:58:53Z</dc:date>
    <item>
      <title>Data Transpose/Pivot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430216#M281576</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1st of all, below is the SAS code for the data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input zip $ item $ box1 box2 box3 percent;
	format percent percent. ;

	datalines;
		00501 22 1 1 0 0.1
		00501 42 2 0 0 0.3
		00501 99 1 1 6 0.6
		00101 22 2 10 30 0.28
		00101 23 48 24 60 0.45
		00101 31 40 20 50 1
		00101 42 56 36 70 0.42
		;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Which will give you this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS Transpose 1.png" style="width: 320px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18047iC5B92664B35BE910/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS Transpose 1.png" alt="SAS Transpose 1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to ask for the simplest solution to be able to go from that table, to a semi-transposed (or technically, a pivoted) dataset.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS Transpose 2.png" style="width: 496px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18048iC9498B85E00DC0CD/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS Transpose 2.png" alt="SAS Transpose 2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The item codes will be constant. Below are all the possible item codes if it matters:&lt;/P&gt;&lt;PRE&gt;22
23
31
42
52
62
72
82
99&lt;/PRE&gt;&lt;P&gt;Any help pointing me to the right direction will be very much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tony&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 23:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430216#M281576</guid>
      <dc:creator>Tony5</dc:creator>
      <dc:date>2018-01-23T23:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transpose/Pivot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430217#M281577</link>
      <description>&lt;P&gt;PROC TRANSPOSE will transform the data, or PROC TABULATE works if you just want a printed report.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by zip item;
run;

proc transpose data=have out=want prefix=item;
by zip ;
var percent;
id item;
idlabel item;
run;&lt;BR /&gt;&lt;BR /&gt;proc print data=want;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187899"&gt;@Tony5&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi again,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1st of all, below is the SAS code for the data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input zip $ item $ box1 box2 box3 percent;
	format percent percent. ;

	datalines;
		00501 22 1 1 0 0.1
		00501 42 2 0 0 0.3
		00501 99 1 1 6 0.6
		00101 22 2 10 30 0.28
		00101 23 48 24 60 0.45
		00101 31 40 20 50 1
		00101 42 56 36 70 0.42
		;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will give you this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS Transpose 1.png" style="width: 320px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18047iC5B92664B35BE910/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS Transpose 1.png" alt="SAS Transpose 1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to ask for the simplest solution to be able to go from that table, to a semi-transposed (or technically, a pivoted) dataset.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS Transpose 2.png" style="width: 496px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18048iC9498B85E00DC0CD/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS Transpose 2.png" alt="SAS Transpose 2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The item codes will be constant. Below are all the possible item codes if it matters:&lt;/P&gt;
&lt;PRE&gt;22
23
31
42
52
62
72
82
99&lt;/PRE&gt;
&lt;P&gt;Any help pointing me to the right direction will be very much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Tony&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 23:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430217#M281577</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-23T23:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transpose/Pivot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430228#M281578</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187899"&gt;@Tony5&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi again,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to ask for the simplest solution to be able to go from that table, to a semi-transposed (or technically, a pivoted) dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Data sets don't really "pivot" that is very much a spreadsheet term.&lt;/P&gt;
&lt;P&gt;What role to the BOX values in calculating your results? I am not sure what the denominators or numerators are for any of those result cells in your "want".&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 00:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430228#M281578</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-24T00:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transpose/Pivot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430236#M281579</link>
      <description>&lt;P&gt;Thank you so much for the solution Reeza. It worked beautifully! And your assumption is on point, I do need the transposed table as a dataset (as opposed to a printout).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will research more what TRANSPOSE does. For starters, it seems that PREFIX, ID, and IDLABEL would be the same thing most of the time.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 00:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430236#M281579</guid>
      <dc:creator>Tony5</dc:creator>
      <dc:date>2018-01-24T00:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transpose/Pivot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430237#M281580</link>
      <description>&lt;P&gt;Thanks for the response ballardw.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess my Excel roots are showing up. Hehe.&lt;/P&gt;&lt;P&gt;To answer your question, I actually just need the last column to show up (the "percent" variable). All box values will be dropped.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case though, Reeza was able to provide a solution a few minutes ago. Still, I appreciate your support. Have a great day ahead!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 00:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430237#M281580</guid>
      <dc:creator>Tony5</dc:creator>
      <dc:date>2018-01-24T00:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transpose/Pivot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430240#M281581</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187899"&gt;@Tony5&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much for the solution Reeza. It worked beautifully! And your assumption is on point, I do need the transposed table as a dataset (as opposed to a printout).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will research more what TRANSPOSE does. For starters, it seems that PREFIX, ID, and IDLABEL would be the same thing most of the time.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you don't&amp;nbsp;use the ID statement to tell&amp;nbsp;PROC TRANSPOSE how to name the variables they will just be named COL1,COL2,...&lt;/P&gt;
&lt;P&gt;If you do give it an ID statement and try to use a numeric variable for generating the names you could have a problem since you can't make a variable with a number for a name like in your original request.&amp;nbsp; If you don't specify a PREFIX then SAS will use _ as a prefix to turn the numbers into valid variable names.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IDLABEL statement is in case you have a variable that want to use as source for the LABEL of the new variables.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 01:14:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430240#M281581</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-01-24T01:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transpose/Pivot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430248#M281582</link>
      <description>Super helpful. Thanks Tom!</description>
      <pubDate>Wed, 24 Jan 2018 01:58:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Transpose-Pivot/m-p/430248#M281582</guid>
      <dc:creator>Tony5</dc:creator>
      <dc:date>2018-01-24T01:58:47Z</dc:date>
    </item>
  </channel>
</rss>

