<?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/466808#M119157</link>
    <description>&lt;P&gt;I'd recommend trying&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;'s transpose macro if that can help. The details are available in the library. If he has the time, I'm sure Art will point you in the right direction&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jun 2018 11:57:15 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-06-01T11:57:15Z</dc:date>
    <item>
      <title>Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466524#M119042</link>
      <description>&lt;P&gt;I have data in mentioned below format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Col-1&lt;/TD&gt;&lt;TD&gt;Col-2&lt;/TD&gt;&lt;TD&gt;Col-3&lt;/TD&gt;&lt;TD&gt;Col-4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;product-1&lt;/TD&gt;&lt;TD&gt;LAI&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;25.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;product-1&lt;/TD&gt;&lt;TD&gt;LEX&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;17.50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;product-2&lt;/TD&gt;&lt;TD&gt;LAI&lt;/TD&gt;&lt;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TD&gt;&lt;TD&gt;17.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;product-2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;product-3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;16.2&lt;/TD&gt;&lt;TD&gt;199&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;product-4&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;88&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 15:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466524#M119042</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2018-05-31T15:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466528#M119044</link>
      <description>See Example 3 and beyond here: &lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/&lt;/A&gt;</description>
      <pubDate>Thu, 31 May 2018 15:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466528#M119044</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-31T15:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466539#M119048</link>
      <description>&lt;P&gt;demo:&lt;/P&gt;&lt;P&gt;you need a double transpose with careful grouping variables i.e you should know how to group&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input Col1 :$20.	Col2 $	Col3	Col4 ;
cards;
product-1	LAI	1	25.00
product-1	LEX	2	17.50
product-2	LAI	1	9.00
product-2	LEX	1	25.00
product-3	LAI	1	16.20
product-3	LEX	1	199.00
product-4	LAI	1	30.00
product-4	LEX	4	88.00
;
proc transpose data=have out=w prefix=l;
by col1 col2;
var  col3 col4;
run;
proc transpose data=w out=final_want(drop=_:)  prefix=l ;
by col1 ;
var l1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 May 2018 16:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466539#M119048</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-31T16:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466542#M119049</link>
      <description>&lt;P&gt;Just getting the order of vars right with an added sort:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
infile cards truncover;
input Col1 :$20.	Col2 $	Col3	Col4 ;
cards;
product-1	LAI	1	25.00
product-1	LEX	2	17.50
product-2	LAI	1	9.00
product-2	LEX	1	25.00
product-3	LAI	1	16.20
product-3	LEX	1	199.00
product-4	LAI	1	30.00
product-4	LEX	4	88.00
;
proc transpose data=have out=w prefix=l;
by col1 col2;
var  col3 col4;
run;
proc sort data=w;
by col1 _name_;
run;
proc transpose data=w out=final_want(drop=_:)  prefix=l ;
by col1 ;
var l1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 May 2018 16:31:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466542#M119049</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-31T16:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466793#M119154</link>
      <description>&lt;P&gt;It was a sample example and there are only two value columns (column3 and column4), my problem is I have multiple value column, by this example I have to transpose it so many times like that. Can we run any loop or something which can take all value column and run in the smaller piece of code?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 10:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466793#M119154</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2018-06-01T10:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466794#M119155</link>
      <description>&lt;P&gt;&lt;SPAN&gt;It was a&amp;nbsp;&lt;/SPAN&gt;sample&lt;SPAN&gt;&amp;nbsp;example and there are only two value columns (column3 and column4), my problem is I have multiple value column, by this example I have to transpose it so many times like that. Can we run any loop or something which can take all value column and run in the smaller piece of code?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 10:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466794#M119155</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2018-06-01T10:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466808#M119157</link>
      <description>&lt;P&gt;I'd recommend trying&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;'s transpose macro if that can help. The details are available in the library. If he has the time, I'm sure Art will point you in the right direction&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 11:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466808#M119157</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-01T11:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466811#M119158</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200312"&gt;@Srigyan&lt;/a&gt;: Unless I'm missing something, I think that a slight variant of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;'s code would meet your need, regardless of the number of values you have for Col2 and Col3:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards truncover;
  input Col1 :$20.    Col2 $  Col3    Col4 ;
  cards;
product-1   LAI 1   25.00
product-1   LEX 2   17.50
product-2   LAI 1   9.00
product-2   LEX 1   25.00
product-3   LAI 1   16.20
product-3   LEX 1   199.00
product-4   LAI 1   30.00
product-4   LEX 4   88.00
;

proc sort data=have;
  by col1 col2;
run;

proc transpose data=have out=w prefix=l;
  by col1 col2;
  var  col3 col4;
run;

data w;
  set w;
  _name_=catx('_',col2,_name_);
run;

proc transpose data=w out=final_want(drop=_:);
  by col1 ;
  var l1;
  id _name_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 12:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466811#M119158</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-06-01T12:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466838#M119159</link>
      <description>&lt;P&gt;OR Merge Skill proposed by me,Arthur.T,Matt .&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings15/2785-2015.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings15/2785-2015.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input Col1 :$20.	Col2 $	Col3	Col4 ;
cards;
product-1	LAI	1	25.00
product-1	LEX	2	17.50
product-2	LAI	1	9.00
product-2	LEX	1	25.00
product-3	LAI	1	16.20
product-3	LEX	1	199.00
product-4	LAI	1	30.00
product-4	LEX	4	88.00
;
proc sql noprint;
select distinct catt('have(where=(col2="',col2,'")
rename=(col3=',col2,'_col3 col4=',col2,'_col4))')
into : list separated by ' '
 from have;
quit;
data want;
 merge &amp;amp;list;
 by col1 ;
 drop col2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jun 2018 14:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466838#M119159</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-06-01T14:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466850#M119160</link>
      <description>&lt;P&gt;Art - How is building your own variable name&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w;
  set w;
  _name_=catx('_',col2,_name_);
run;

proc transpose data=w out=final_want(drop=_:);
  by col1 ;
  var l1;
  id _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Different than letting SAS build the variable name?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=w out=final_want(drop=_:);
  by col1 ;
  var l1;
  id col2 _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jun 2018 14:35:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466850#M119160</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-01T14:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466857#M119162</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;: It added in the _ delimiter that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200312"&gt;@Srigyan&lt;/a&gt;&amp;nbsp;indicated was wanted between the col2 and col3 values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, I agree, they both do the same thing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 14:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466857#M119162</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-06-01T14:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466858#M119163</link>
      <description>&lt;P&gt;That is what the DELIMITER= option on the PROC TRANSPOSE statement is for.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN class="strong"&gt;DELIMITER=&lt;SPAN class="strongEmph"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;delimiter&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;specifies a delimiter to use in constructing names for transposed variables in the output data set. If specified, the delimiter will be inserted between variable values if more than one variable has been specified on the ID statement.&lt;/P&gt;
&lt;TABLE cellspacing="2" cellpadding="4"&gt;
&lt;TBODY&gt;
&lt;TR valign="top"&gt;
&lt;TD width="95" align="left" class="label"&gt;Alias:&lt;/TD&gt;
&lt;TD align="left" class="bgBlockLight"&gt;DELIM=&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 14:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466858#M119163</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-01T14:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466873#M119166</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;: Agreed! The extra datastep can be avoided:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards truncover;
  input Col1 :$20.    Col2 $  Col3    Col4 ;
  cards;
product-1   LAI 1   25.00
product-1   LEX 2   17.50
product-2   LAI 1   9.00
product-2   LEX 1   25.00
product-3   LAI 1   16.20
product-3   LEX 1   199.00
product-4   LAI 1   30.00
product-4   LEX 4   88.00
;

proc sort data=have;
  by col1 col2;
run;

proc transpose data=have out=w prefix=l;
  by col1 col2;
  var  col3 col4;
run;

proc transpose data=w out=want (drop=_:) delimiter=_;
  by col1 ;
  var l1;
  id col2 _name_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 15:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/466873#M119166</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-06-01T15:14:47Z</dc:date>
    </item>
  </channel>
</rss>

