<?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: Transpose Wide to Long while duplicating qualitative data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67440#M19284</link>
    <description>Hello GlenGold,&lt;BR /&gt;
&lt;BR /&gt;
This is a transpose based solution:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
input Product UPC Form Type Week1 Week2 Week3 Week4 Unit1 Unit2 Unit3 Unit4;&lt;BR /&gt;
cards;&lt;BR /&gt;
01 01 01 01 05 06 07 08 09 10 11 12&lt;BR /&gt;
02 02 02 03 21 22 23 24 25 26 27 28&lt;BR /&gt;
01 01 01 02 13 14 15 16 17 18 19 20&lt;BR /&gt;
02 02 02 04 29 30 31 32 33 34 35 36&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=i;&lt;BR /&gt;
  by Product UPC Form Type;&lt;BR /&gt;
run;&lt;BR /&gt;
proc transpose data=i out=w (drop=_:) prefix=Amount;&lt;BR /&gt;
  var week1-week4;&lt;BR /&gt;
  by Product UPC Form Type;&lt;BR /&gt;
run; &lt;BR /&gt;
proc transpose data=i out=u (drop=_:) prefix=Sales;&lt;BR /&gt;
  var Unit1-Unit4;&lt;BR /&gt;
  by Product UPC Form Type;&lt;BR /&gt;
run; &lt;BR /&gt;
data r;&lt;BR /&gt;
  merge w u;&lt;BR /&gt;
  by Product UPC Form Type;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
    <pubDate>Thu, 19 May 2011 20:19:33 GMT</pubDate>
    <dc:creator>SPR</dc:creator>
    <dc:date>2011-05-19T20:19:33Z</dc:date>
    <item>
      <title>Transpose Wide to Long while duplicating qualitative data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67435#M19279</link>
      <description>I have a data set with weekly sales and units for the year in each row.  There are also many qualitative variables such as product form, type, size, etc.  I need the data transposed so that the sales and units for each week are on a separate row, and the qualitative variables are duplicated for each entry.&lt;BR /&gt;
&lt;BR /&gt;
Example:&lt;BR /&gt;
&lt;BR /&gt;
Product   UPC   Form   Type   Week1  Week2  Week3  Week4  Unit1  Unit2  Unit3  Unit4&lt;BR /&gt;
&lt;BR /&gt;
I need:&lt;BR /&gt;
&lt;BR /&gt;
Product  UPC  Form  Type  Week1  Unit1&lt;BR /&gt;
Product  UPC  Form  Type  Week2  Unit2&lt;BR /&gt;
Product  UPC  Form  Type  Week3  Unit3&lt;BR /&gt;
Product  UPC  Form  Type  Week4  Unit4&lt;BR /&gt;
&lt;BR /&gt;
I created a macro in excel and it was working but I ran out of rows!  This set will be 1.5 million rows when done, excel has a max ~1 mill.  I found some information on a macro in SAS which does this but couldn't get it to install.  I've never used macros in sas</description>
      <pubDate>Thu, 19 May 2011 14:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67435#M19279</guid>
      <dc:creator>GlenGold</dc:creator>
      <dc:date>2011-05-19T14:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Wide to Long while duplicating qualitative data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67436#M19280</link>
      <description>Well I did the transposing in Enterprise Guide and am left with two sets, one with sales, one with units.  I cannot find a way to merge them together.</description>
      <pubDate>Thu, 19 May 2011 16:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67436#M19280</guid>
      <dc:creator>GlenGold</dc:creator>
      <dc:date>2011-05-19T16:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Wide to Long while duplicating qualitative data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67437#M19281</link>
      <description>Something like this???&lt;BR /&gt;
&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
&lt;BR /&gt;
data foo;&lt;BR /&gt;
 input Product UPC Form Type Week1 Week2 Week3 Week4 Unit1 Unit2 Unit3 Unit4;&lt;BR /&gt;
 cards;&lt;BR /&gt;
 01 01 01 01 05 06 07 08 09 10 11 12&lt;BR /&gt;
 02 02 02 02 21 22 23 24 25 26 27 28&lt;BR /&gt;
 01 01 01 01 13 14 15 16 17 18 19 20&lt;BR /&gt;
 02 02 02 02 29 30 31 32 33 34 35 36&lt;BR /&gt;
 ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=foo;&lt;BR /&gt;
 by Product UPC Form Type;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data bar;&lt;BR /&gt;
 set foo;&lt;BR /&gt;
 by Product UPC Form Type;&lt;BR /&gt;
 array W[4] Week1-Week4;&lt;BR /&gt;
 array U[4] Unit1-Unit4;&lt;BR /&gt;
 do i=1 to 4;&lt;BR /&gt;
  Week=W&lt;I&gt;;&lt;BR /&gt;
  Unit=U&lt;I&gt;;&lt;BR /&gt;
  index=i;&lt;BR /&gt;
  output;&lt;BR /&gt;
 end;&lt;BR /&gt;
&lt;BR /&gt;
 drop i;&lt;BR /&gt;
 drop Week1 Week2 Week3 Week4;&lt;BR /&gt;
 drop Unit1 Unit2 Unit3 Unit4;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=bar;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;/I&gt;&lt;/I&gt;&lt;/CODE&gt;&lt;I&gt;&lt;I&gt;

Message was edited by: scmebu&lt;/I&gt;&lt;/I&gt;</description>
      <pubDate>Thu, 19 May 2011 16:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67437#M19281</guid>
      <dc:creator>scmebu</dc:creator>
      <dc:date>2011-05-19T16:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Wide to Long while duplicating qualitative data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67438#M19282</link>
      <description>Sorry, I'm having problems preserving the text of the code when it's posted.</description>
      <pubDate>Thu, 19 May 2011 16:37:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67438#M19282</guid>
      <dc:creator>scmebu</dc:creator>
      <dc:date>2011-05-19T16:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Wide to Long while duplicating qualitative data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67439#M19283</link>
      <description>ods html close;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
&lt;BR /&gt;
data foo;&lt;BR /&gt;
 input Product UPC Form Type Week1 Week2 Week3 Week4 Unit1 Unit2 Unit3 Unit4;&lt;BR /&gt;
 cards;&lt;BR /&gt;
 01 01 01 01 05 06 07 08 09 10 11 12&lt;BR /&gt;
 02 02 02 02 21 22 23 24 25 26 27 28&lt;BR /&gt;
 01 01 01 01 13 14 15 16 17 18 19 20&lt;BR /&gt;
 02 02 02 02 29 30 31 32 33 34 35 36&lt;BR /&gt;
 ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=foo;&lt;BR /&gt;
 by Product UPC Form Type;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data bar;&lt;BR /&gt;
 set foo;&lt;BR /&gt;
 by Product UPC Form Type;&lt;BR /&gt;
 array W[4] Week1-Week4;&lt;BR /&gt;
 array U[4] Unit1-Unit4;&lt;BR /&gt;
 do i=1 to 4;&lt;BR /&gt;
  Week=W [ i ];&lt;BR /&gt;
  Unit=U [ i ];&lt;BR /&gt;
  index=i;&lt;BR /&gt;
  output;&lt;BR /&gt;
 end;&lt;BR /&gt;
&lt;BR /&gt;
 drop i;&lt;BR /&gt;
 drop Week1 Week2 Week3 Week4;&lt;BR /&gt;
 drop Unit1 Unit2 Unit3 Unit4;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=bar;&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 19 May 2011 16:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67439#M19283</guid>
      <dc:creator>scmebu</dc:creator>
      <dc:date>2011-05-19T16:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Wide to Long while duplicating qualitative data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67440#M19284</link>
      <description>Hello GlenGold,&lt;BR /&gt;
&lt;BR /&gt;
This is a transpose based solution:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
input Product UPC Form Type Week1 Week2 Week3 Week4 Unit1 Unit2 Unit3 Unit4;&lt;BR /&gt;
cards;&lt;BR /&gt;
01 01 01 01 05 06 07 08 09 10 11 12&lt;BR /&gt;
02 02 02 03 21 22 23 24 25 26 27 28&lt;BR /&gt;
01 01 01 02 13 14 15 16 17 18 19 20&lt;BR /&gt;
02 02 02 04 29 30 31 32 33 34 35 36&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=i;&lt;BR /&gt;
  by Product UPC Form Type;&lt;BR /&gt;
run;&lt;BR /&gt;
proc transpose data=i out=w (drop=_:) prefix=Amount;&lt;BR /&gt;
  var week1-week4;&lt;BR /&gt;
  by Product UPC Form Type;&lt;BR /&gt;
run; &lt;BR /&gt;
proc transpose data=i out=u (drop=_:) prefix=Sales;&lt;BR /&gt;
  var Unit1-Unit4;&lt;BR /&gt;
  by Product UPC Form Type;&lt;BR /&gt;
run; &lt;BR /&gt;
data r;&lt;BR /&gt;
  merge w u;&lt;BR /&gt;
  by Product UPC Form Type;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Thu, 19 May 2011 20:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Transpose-Wide-to-Long-while-duplicating-qualitative-data/m-p/67440#M19284</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-05-19T20:19:33Z</dc:date>
    </item>
  </channel>
</rss>

