<?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 transpose data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56619#M15817</link>
    <description>All,&lt;BR /&gt;
&lt;BR /&gt;
I have data  foramt such as:&lt;BR /&gt;
Search_methods	week_beginning	count&lt;BR /&gt;
Online Banking	03/28/11	                  1&lt;BR /&gt;
Online Banking	04/11/11	                9&lt;BR /&gt;
Online Banking	04/18/11	                28&lt;BR /&gt;
Search by Name	04/04/11	                 1&lt;BR /&gt;
Search by Name	04/11/11	                  1&lt;BR /&gt;
Search by Name	04/18/11	                4&lt;BR /&gt;
Search by Reservation 04/11/11              	8&lt;BR /&gt;
Search by Reservation04/18/11              	42&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
need to transpose to the following format:&lt;BR /&gt;
&lt;BR /&gt;
Offer Search Methods	 3/28/2011	4/4/2011	4/11/2011  04/18/11&lt;BR /&gt;
Online Banking	   1	0	9                28 &lt;BR /&gt;
Search by Name	    0	1	1               4&lt;BR /&gt;
Search by ReservatioN   0	0	8              42&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.</description>
    <pubDate>Mon, 25 Apr 2011 20:48:34 GMT</pubDate>
    <dc:creator>QLi</dc:creator>
    <dc:date>2011-04-25T20:48:34Z</dc:date>
    <item>
      <title>transpose data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56619#M15817</link>
      <description>All,&lt;BR /&gt;
&lt;BR /&gt;
I have data  foramt such as:&lt;BR /&gt;
Search_methods	week_beginning	count&lt;BR /&gt;
Online Banking	03/28/11	                  1&lt;BR /&gt;
Online Banking	04/11/11	                9&lt;BR /&gt;
Online Banking	04/18/11	                28&lt;BR /&gt;
Search by Name	04/04/11	                 1&lt;BR /&gt;
Search by Name	04/11/11	                  1&lt;BR /&gt;
Search by Name	04/18/11	                4&lt;BR /&gt;
Search by Reservation 04/11/11              	8&lt;BR /&gt;
Search by Reservation04/18/11              	42&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
need to transpose to the following format:&lt;BR /&gt;
&lt;BR /&gt;
Offer Search Methods	 3/28/2011	4/4/2011	4/11/2011  04/18/11&lt;BR /&gt;
Online Banking	   1	0	9                28 &lt;BR /&gt;
Search by Name	    0	1	1               4&lt;BR /&gt;
Search by ReservatioN   0	0	8              42&lt;BR /&gt;
 &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.</description>
      <pubDate>Mon, 25 Apr 2011 20:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56619#M15817</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2011-04-25T20:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: transpose data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56620#M15818</link>
      <description>Hello QLi,&lt;BR /&gt;
&lt;BR /&gt;
This is a solution:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
  input Search_methods $ 1-21 week_beginning $ 23-30 count 32-33;&lt;BR /&gt;
datalines;&lt;BR /&gt;
Online Banking        03/28/11 1&lt;BR /&gt;
Online Banking        04/11/11 9&lt;BR /&gt;
Online Banking        04/18/11 28&lt;BR /&gt;
Search by Name        04/04/11 1&lt;BR /&gt;
Search by Name        04/11/11 1&lt;BR /&gt;
Search by Name        04/18/11 4&lt;BR /&gt;
Search by Reservation 04/11/11 8&lt;BR /&gt;
Search by Reservation 04/18/11 42&lt;BR /&gt;
run;&lt;BR /&gt;
proc transpose data=i out=r (drop=_name_);&lt;BR /&gt;
  var Count;&lt;BR /&gt;
  id week_beginning; &lt;BR /&gt;
  by Search_methods;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Mon, 25 Apr 2011 21:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56620#M15818</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-04-25T21:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: transpose data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56621#M15819</link>
      <description>Thanks for your response. &lt;BR /&gt;
&lt;BR /&gt;
according to the code;&lt;BR /&gt;
proc transpose data=web out=T_web (drop=_name_ _label_) ;&lt;BR /&gt;
var   count;&lt;BR /&gt;
id week_beginning ;&lt;BR /&gt;
by Search_methods;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
the result is the following. &lt;BR /&gt;
Search_methods	03/28/11	04/11/11	04/18/11	04/04/11&lt;BR /&gt;
Online Banking	  1	9	28	0&lt;BR /&gt;
Search by Name	   0	1	4	1&lt;BR /&gt;
Search by Reservation  0	8	42	0&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The week beginning can not be ordered. I want to them in the order of 03/28/11,04/04/11, 04/11/11,04/18/11.&lt;BR /&gt;
&lt;BR /&gt;
I want to transpose by search methods at the same time week beginnings in order.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,,</description>
      <pubDate>Mon, 25 Apr 2011 21:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56621#M15819</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2011-04-25T21:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: transpose data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56622#M15820</link>
      <description>How about this:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
  input Search_methods $ 1-21 week_beginning : mmddyy10. count 32-33;&lt;BR /&gt;
  format week_beginning mmddyy8.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
Online Banking        03/28/11 1&lt;BR /&gt;
Online Banking        04/11/11 9&lt;BR /&gt;
Online Banking        04/18/11 28&lt;BR /&gt;
Search by Name        04/04/11 1&lt;BR /&gt;
Search by Name        04/11/11 1&lt;BR /&gt;
Search by Name        04/18/11 4&lt;BR /&gt;
Search by Reservation 04/11/11 8&lt;BR /&gt;
Search by Reservation 04/18/11 42&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 create table temp as&lt;BR /&gt;
  select *&lt;BR /&gt;
   from (select distinct search_methods from i),(select distinct week_beginning from i)&lt;BR /&gt;
    order by search_methods&lt;BR /&gt;
    ;&lt;BR /&gt;
&lt;BR /&gt;
 create table op as&lt;BR /&gt;
  select temp.search_methods,temp.week_beginning,coalesce(i.count,0) as count&lt;BR /&gt;
   from temp left join i &lt;BR /&gt;
    on temp.search_methods = i.search_methods &lt;BR /&gt;
       and temp.week_beginning = i.week_beginning&lt;BR /&gt;
  ;&lt;BR /&gt;
quit;&lt;BR /&gt;
options validvarname=any;&lt;BR /&gt;
proc transpose data=op out=want(drop=_name_ ) ;&lt;BR /&gt;
 by search_methods;&lt;BR /&gt;
 id week_beginning;&lt;BR /&gt;
 var count;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 26 Apr 2011 03:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56622#M15820</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-26T03:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: transpose data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56623#M15821</link>
      <description>QLi,&lt;BR /&gt;
&lt;BR /&gt;
Couldn't you obtain what you want with proc report?  E.g.,&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc report list nowd split='~';&lt;BR /&gt;
  columns Search_methods week_beginning,(count dummy);&lt;BR /&gt;
  define Search_methods / group 'Search_methods' '--';&lt;BR /&gt;
  define week_beginning/ across; /*ordered by date*/&lt;BR /&gt;
  define count / sum width=10 '--';&lt;BR /&gt;
  define dummy / noprint;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]

Message was edited by: art297</description>
      <pubDate>Tue, 26 Apr 2011 12:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56623#M15821</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-04-26T12:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: transpose data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56624#M15822</link>
      <description>Art297, &lt;BR /&gt;
&lt;BR /&gt;
It works great.&lt;BR /&gt;
&lt;BR /&gt;
Thank you very much!!</description>
      <pubDate>Tue, 26 Apr 2011 12:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56624#M15822</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2011-04-26T12:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: transpose data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56625#M15823</link>
      <description>Ksharp,&lt;BR /&gt;
&lt;BR /&gt;
I tried your method. It worked great. Thank for your help.</description>
      <pubDate>Tue, 26 Apr 2011 12:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/transpose-data/m-p/56625#M15823</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2011-04-26T12:56:08Z</dc:date>
    </item>
  </channel>
</rss>

