<?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: Merge Table Headers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770137#M244289</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Yes. Thank&amp;nbsp; you so much.&lt;/P&gt;&lt;P&gt;Sorry for if i made some confusions with regards to my previous posts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Sep 2021 07:40:10 GMT</pubDate>
    <dc:creator>maricelj</dc:creator>
    <dc:date>2021-09-24T07:40:10Z</dc:date>
    <item>
      <title>Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770101#M244259</link>
      <description>Hi there!&lt;BR /&gt;I need your help.&lt;BR /&gt;I have this table and the headers contain year with its months next to it. Is there a way to do it wherein the output would be in the created table?&lt;BR /&gt;Sample output be like this:&lt;BR /&gt;Name | Item | Year 2021&lt;BR /&gt;| | 01 | 02 | 03 | 04 | 05 | 06| 07| 08 | 09| 10 | 11| 12&lt;BR /&gt;&lt;BR /&gt;Hope to hear from you.&lt;BR /&gt;Thank you and keep safe.</description>
      <pubDate>Fri, 24 Sep 2021 05:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770101#M244259</guid>
      <dc:creator>maricelj</dc:creator>
      <dc:date>2021-09-24T05:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770104#M244261</link>
      <description>&lt;P&gt;Please post an excerpt of the data you have as working data step and re-format the layout you want by posting it using "insert code", so that blanks aren't deleted.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 05:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770104#M244261</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-09-24T05:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770111#M244268</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;The code goes like this:&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE Test AS&lt;BR /&gt;SELECT DISTINCT&lt;BR /&gt;ID as ID, Name&lt;BR /&gt;TRANS_MONTH&lt;BR /&gt;FROM Transaction&lt;BR /&gt;WHERE year = '2021'&lt;BR /&gt;ORDER BY ID;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the output to have a year above each trans_month but such year should appear only once and no idea how to do it.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
	CREATE TABLE Test AS 
		SELECT DISTINCT
			ID, Name
			TRANS_MONTH
			FROM Transaction
			WHERE year = '2021'
			ORDER BY ID;
QUIT;

Output be like this:
ID | NAME |                            YEAR 2021
   |      | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12

Thank you.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 05:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770111#M244268</guid>
      <dc:creator>maricelj</dc:creator>
      <dc:date>2021-09-24T05:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770120#M244273</link>
      <description>&lt;P&gt;So you don't want to produce a dataset at all.&amp;nbsp; What you are showing is a REPORT.&lt;/P&gt;
&lt;P&gt;So perhaps something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=transaction ;&lt;BR /&gt;  where year='2021';
  column id name year,trans_month;
  define id / group;
  define name / group;
  define year / across;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 06:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770120#M244273</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-24T06:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770128#M244280</link>
      <description>&lt;P&gt;You show us code (that won't run, BTW, because of a missing comma), but not data.&lt;/P&gt;
&lt;P&gt;Pleaee give us examples of your three variables, preferrably in a data step with datalines.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 07:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770128#M244280</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-24T07:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770129#M244281</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Sorry if it's kind of confusing.&lt;/P&gt;&lt;P&gt;I just can't add a table here so I made such presentation which seemed to be a report.&lt;/P&gt;&lt;P&gt;Actually, it's not yet a report instead, it's a dataset.&lt;/P&gt;&lt;P&gt;It's a table and I want the column headers be like that, if it's possible.&lt;/P&gt;&lt;P&gt;My report is in excel format which such table is being called through a macro.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 07:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770129#M244281</guid>
      <dc:creator>maricelj</dc:creator>
      <dc:date>2021-09-24T07:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770132#M244284</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Sorry for that.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Test;
  input ID Name _01 _02 _03 _04 _05 _06 _07 _08 _09 _10 _11 _12;
  cards;
1 a 10 1 2 3 1 4 5 4 5 1 5 1
2 b 12 3 3 4 5 6 5 4 6 5 4 2
3 c 2 2 1 3 1 3 4 5 2 3 5 3
;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a way that I can add label which is the year (2021) on top of the months?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;maricelj&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 07:20:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770132#M244284</guid>
      <dc:creator>maricelj</dc:creator>
      <dc:date>2021-09-24T07:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770133#M244285</link>
      <description>&lt;P&gt;You can always add a table here. You already gave us the column names, so those should not be sensitive.&lt;/P&gt;
&lt;P&gt;Make up some fake data, like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $ name $ trans_month;
datalines;
XXX YYYY 1
XXX YYYY 2
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;that is &lt;EM&gt;representative&lt;/EM&gt; of what you really have. Don't forget to include "edge" cases, like certain missing values etc.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 07:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770133#M244285</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-24T07:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770134#M244286</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/395727"&gt;@maricelj&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;Is there a way that I can add label which is the year (2021) on top of the months?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not in a dataset; datasets do not have the concept of column-spanning labels, but reports have.&lt;/P&gt;
&lt;P&gt;Like&lt;/P&gt;
&lt;PRE&gt;data Test;
  input ID $ Name $ _01 _02 _03 _04 _05 _06 _07 _08 _09 _10 _11 _12;
  cards;
1 a 10 1 2 3 1 4 5 4 5 1 5 1
2 b 12 3 3 4 5 6 5 4 6 5 4 2
3 c 2 2 1 3 1 3 4 5 2 3 5 3
;

proc transpose data=test out=long;
by id name;
var _:;
run;

proc report data=long;
column id name col1,_name_;
define id /group;
define name / group;
define col1 / "" analysis;
define _name_ / "2021" across;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Sep 2021 07:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770134#M244286</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-24T07:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770136#M244288</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Oh I see. Thank you.&lt;/P&gt;&lt;P&gt;By the way, is there a way to import such report in an excel format?&lt;/P&gt;&lt;P&gt;I am very much overwhelmed because of the fast response I am getting here. Thank you very much.&lt;/P&gt;&lt;P&gt;Sorry if I made some confusions with regards to my previous posts.&lt;/P&gt;&lt;P&gt;Keep safe.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 07:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770136#M244288</guid>
      <dc:creator>maricelj</dc:creator>
      <dc:date>2021-09-24T07:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770137#M244289</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Yes. Thank&amp;nbsp; you so much.&lt;/P&gt;&lt;P&gt;Sorry for if i made some confusions with regards to my previous posts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 07:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770137#M244289</guid>
      <dc:creator>maricelj</dc:creator>
      <dc:date>2021-09-24T07:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770138#M244290</link>
      <description>&lt;P&gt;First, let's get our wording straightened up. When we ("the SAS people") say IMPORT, we mean to bring external data &lt;STRONG&gt;into&lt;/STRONG&gt; the SAS environment. So we &lt;EM&gt;import&lt;/EM&gt; Excel data into SAS. When we create Excel files from SAS data, we call than an EXPORT.&lt;/P&gt;
&lt;P&gt;Similarly, the procedures often used for this are also called IMPORT and EXPORT, respectively.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get a report to Excel, just use ODS (the Output Delivery System):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file="$HOME/report.xlsx";

proc report data=long;
column id name col1,_name_;
define id /group;
define name / group;
define col1 / "" analysis;
define _name_ / "2021" across;
run;

ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use a path name proper for your environment in the FILE= option of the ODS statement.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 07:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770138#M244290</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-24T07:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Table Headers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770141#M244291</link>
      <description>Hey there,&lt;BR /&gt;Yeah. I mean export.&lt;BR /&gt;Thanks for your help.&lt;BR /&gt;Got it and it works!&lt;BR /&gt;Please keep safe.</description>
      <pubDate>Fri, 24 Sep 2021 07:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Table-Headers/m-p/770141#M244291</guid>
      <dc:creator>maricelj</dc:creator>
      <dc:date>2021-09-24T07:56:17Z</dc:date>
    </item>
  </channel>
</rss>

