<?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: Transform Long to Wide Format in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339872#M77583</link>
    <description>&lt;P&gt;Yes, it's pretty much what I'm heading to now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I'm standardizing inputs in the long format.&lt;/P&gt;&lt;P&gt;2. proc transpose each one of them&lt;/P&gt;&lt;P&gt;3. append the results from step 2. in the needed variable order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2017 04:07:55 GMT</pubDate>
    <dc:creator>afiqcjohari</dc:creator>
    <dc:date>2017-03-10T04:07:55Z</dc:date>
    <item>
      <title>Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339854#M77572</link>
      <description>&lt;P&gt;I have 3 tables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TrYear TrMonth Usage&lt;/P&gt;&lt;P&gt;2017 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3000&lt;/P&gt;&lt;P&gt;2017 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TrYear TrMonth Type&amp;nbsp;Usage&lt;/P&gt;&lt;P&gt;2017 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;1200&lt;/P&gt;&lt;P&gt;2017 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1800&lt;/P&gt;&lt;P&gt;2017 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;2017 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TrYear TrMonth Active&lt;/P&gt;&lt;P&gt;2017 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;300&lt;/P&gt;&lt;P&gt;2017 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;400&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to transform these three&amp;nbsp;tables in wide format, so that I'll end up with one table like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Jan-17 Feb-17&lt;/P&gt;&lt;P&gt;Usage &amp;nbsp; &amp;nbsp; 3000 &amp;nbsp; 4000&lt;/P&gt;&lt;P&gt;Usage-A 1200 &amp;nbsp;2000&lt;/P&gt;&lt;P&gt;Usage-B 1800 &amp;nbsp;2000&lt;/P&gt;&lt;P&gt;Active &amp;nbsp; &amp;nbsp; &amp;nbsp;300 &amp;nbsp; &amp;nbsp; 400&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact I have more than 3 tables, and i want to combine all these long tables in 1 big wide table &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 02:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339854#M77572</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-10T02:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339859#M77575</link>
      <description>&lt;P&gt;What's the logic in combining&amp;nbsp;those tables?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 02:37:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339859#M77575</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-10T02:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339863#M77578</link>
      <description>&lt;P&gt;Not sure what you mean by logic. But it's the report template.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The challenge here is that, the numbers are gathered through proc sql, so all of them are in long format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to combine these tables back into the wide format above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm thinking of transforming each long table to wide format and bind them later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I need to get the transformation right first.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 02:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339863#M77578</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-10T02:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339866#M77580</link>
      <description>&lt;P&gt;1. First standardize inputs format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Append - not merge - all tables together&lt;/P&gt;
&lt;P&gt;3. Then either use proc report/tabulate to generate report for display OR proc transpose to transpose if you need a dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your input format should be like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Year Month Metric Value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 03:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339866#M77580</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-10T03:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339872#M77583</link>
      <description>&lt;P&gt;Yes, it's pretty much what I'm heading to now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I'm standardizing inputs in the long format.&lt;/P&gt;&lt;P&gt;2. proc transpose each one of them&lt;/P&gt;&lt;P&gt;3. append the results from step 2. in the needed variable order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 04:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339872#M77583</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-10T04:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339888#M77590</link>
      <description>&lt;P&gt;Notice that my order is switched for 2/3. Think about how many steps you need in your order compared to mine.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 05:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339888#M77590</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-10T05:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339894#M77593</link>
      <description>&lt;P&gt;I see your point. But the thing is, some of the tables are based on more than 1 variable.&lt;/P&gt;&lt;P&gt;Refer to the second table, where there are 2 types of usage.&lt;/P&gt;&lt;P&gt;If you know how can I standardise the second type of table into 1, that your steps will make sense.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 06:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339894#M77593</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-10T06:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339898#M77594</link>
      <description>&lt;P&gt;Table 2 is the exact structure your table should be in, here's some untested code to combine the data shown.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data combined;&lt;/P&gt;
&lt;P&gt;length type $15.;&lt;/P&gt;
&lt;P&gt;Set table1 (in=a)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Table2 (in=b)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Table3 (rename=active=usage in=C);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if a then type='Usage';&lt;/P&gt;
&lt;P&gt;if b then type = catx('-', 'Usage', type);&lt;/P&gt;
&lt;P&gt;if c then type = 'Active';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then transpose or use proc report or tabulate.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 06:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/339898#M77594</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-10T06:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/340621#M77869</link>
      <description>&lt;P&gt;I end up with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7715i7C52DF69B4AD6C09/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;&lt;P&gt;But I'm stuck at transforming this table to similar format as below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7716i8705D653DB38839F/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 02:01:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/340621#M77869</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-14T02:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/340624#M77872</link>
      <description>&lt;P&gt;Use the TRANSPOSE task or a proc transpose.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Type goes into BY group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Untested:&lt;/P&gt;
&lt;P&gt;Proc transpose data=have out=want prefix=D_&lt;/P&gt;
&lt;P&gt;by type; *may need to sort first;&lt;/P&gt;
&lt;P&gt;var usage;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id trminth tryear;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 02:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/340624#M77872</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-14T02:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Transform Long to Wide Format in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/340640#M77881</link>
      <description>Yes, need to sort it first. I can confirm that.</description>
      <pubDate>Tue, 14 Mar 2017 04:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-Long-to-Wide-Format-in-SAS/m-p/340640#M77881</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-14T04:15:38Z</dc:date>
    </item>
  </channel>
</rss>

