<?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: How to convert sas dataset which is in columnar format into flat file? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-sas-dataset-which-is-in-columnar-format-into-flat/m-p/186572#M35322</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That you want the data in a long instead of a wide structure makes sense to me. Below code sample should get you started.&lt;/P&gt;&lt;P&gt;I've also added a variable "date" which you also could create with your real data if you know which date the first month starts from. A SAS Date variable gives you more flexibility (and you still can you formats or functions if you just want to show the month number).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have(drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; length product $4;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array month {36} 8. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i=1 to dim(month);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; month[_i]=_i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do product='PRD1','PRD2','PRD3';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(drop=_: month1-month36);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array month_arr {*} month1-month36;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i=1 to dim(month_arr);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; amount=month_arr[_i];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date=intnx('month','01Jan2012'd,_i-1,'b');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Jul 2014 01:09:23 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2014-07-21T01:09:23Z</dc:date>
    <item>
      <title>How to convert sas dataset which is in columnar format into flat file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-sas-dataset-which-is-in-columnar-format-into-flat/m-p/186570#M35320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #141823; font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 10pt; background-color: #ffffff;"&gt;Hi, Need some suggestion regarding flat file data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #141823; font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 10pt; background-color: #ffffff;"&gt;I have a SAS dataset which is imported as an excel file in SAS which was originally in a pivot report form. Now I want to convert this SAS dataset into flat style.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #141823; font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 10pt; background-color: #ffffff;"&gt;How should I do It??(I can explain in step wise manner)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #141823; font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 10pt; background-color: #ffffff;"&gt;1. An excel file(which is pivot report of some sort of sales data)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #141823; font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 10pt; background-color: #ffffff;"&gt;2.Imported successfully in sas as SAS dataset&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #141823; font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 10pt; background-color: #ffffff;"&gt;3.How to change orientation of data so it is flat structure.????&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #141823; font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 10pt; line-height: 1.5em; background-color: #f6f7f8;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f7f8;"&gt;&lt;SPAN style="line-height: 1.5em; color: #141823; font-size: 10pt; font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif;"&gt;I have already been able to import the file as sas dataset but it its orientation is pivot report format. i.e. I have 1 variable "products" (which is having ten entries) +36 other &lt;/SPAN&gt;&lt;SPAN style="color: #141823; font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif;"&gt;variables&lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5em; color: #141823; font-size: 10pt; font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif;"&gt; which are names of months spread across 3 years. Now what i want is all the 36(month)variables to be transposed into one column say "MONTHS". and this 36 months will repeat for all 10 products (each product*36 months i.e total 360 rows). so that i will get something like this(please refer image)&lt;IMG alt="Capture1.PNG" class="jive-image" src="https://communities.sas.com/legacyfs/online/6847_Capture1.PNG" /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Jul 2014 15:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-sas-dataset-which-is-in-columnar-format-into-flat/m-p/186570#M35320</guid>
      <dc:creator>HarshadMadhamshettiwar</dc:creator>
      <dc:date>2014-07-20T15:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert sas dataset which is in columnar format into flat file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-sas-dataset-which-is-in-columnar-format-into-flat/m-p/186571#M35321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why do you want to transpose the data? Sounds like a report requirement. If so, take a look at PROC TABULATE or PROC REPORT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Jul 2014 20:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-sas-dataset-which-is-in-columnar-format-into-flat/m-p/186571#M35321</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-07-20T20:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert sas dataset which is in columnar format into flat file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-sas-dataset-which-is-in-columnar-format-into-flat/m-p/186572#M35322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That you want the data in a long instead of a wide structure makes sense to me. Below code sample should get you started.&lt;/P&gt;&lt;P&gt;I've also added a variable "date" which you also could create with your real data if you know which date the first month starts from. A SAS Date variable gives you more flexibility (and you still can you formats or functions if you just want to show the month number).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have(drop=_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; length product $4;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array month {36} 8. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i=1 to dim(month);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; month[_i]=_i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do product='PRD1','PRD2','PRD3';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(drop=_: month1-month36);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array month_arr {*} month1-month36;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i=1 to dim(month_arr);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; amount=month_arr[_i];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date=intnx('month','01Jan2012'd,_i-1,'b');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 01:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-sas-dataset-which-is-in-columnar-format-into-flat/m-p/186572#M35322</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-07-21T01:09:23Z</dc:date>
    </item>
  </channel>
</rss>

