<?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: &amp;quot;merge&amp;quot; numoerous tables but side by side in a new table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921728#M362963</link>
    <description>I tried your code and that's exactly what i wanted. Thank you very much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Mon, 25 Mar 2024 18:05:15 GMT</pubDate>
    <dc:creator>MaxiHösi</dc:creator>
    <dc:date>2024-03-25T18:05:15Z</dc:date>
    <item>
      <title>"merge" numoerous tables but side by side in a new table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921269#M362802</link>
      <description>&lt;P&gt;Hello SAS-Forum,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have problems merging numerous tables side by side in a new table.&lt;/P&gt;&lt;P&gt;I have the collumns car, value and period (for an example see below)&lt;/P&gt;&lt;P&gt;Car:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; value:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;period:&lt;/P&gt;&lt;P&gt;Renault&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10.002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/P&gt;&lt;P&gt;Toyota&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12.000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hyundai&amp;nbsp; &amp;nbsp; &amp;nbsp; 8.000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&lt;/P&gt;&lt;P&gt;Renault&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11.099&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/P&gt;&lt;P&gt;Toyota&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12.054&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hyundai&amp;nbsp; &amp;nbsp; &amp;nbsp; 8.038&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/P&gt;&lt;P&gt;Jaguar&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20.038&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/P&gt;&lt;P&gt;Renault&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9.035&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&lt;/P&gt;&lt;P&gt;Toyota&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10.154&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hyundai&amp;nbsp; &amp;nbsp; &amp;nbsp; 7.600&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/P&gt;&lt;P&gt;....&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to write a new table that looks like that (in one table):&lt;/P&gt;&lt;P&gt;Car_A:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; value_A:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Car_B:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; value_B:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Car_C:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; value_C:&amp;nbsp; &amp;nbsp; ....&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Renault&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10.002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Renault&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11.099&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;Renault&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 9.035&lt;/P&gt;&lt;P&gt;Toyota&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12.000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Toyota&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12.054&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Toyota&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10.154&lt;/P&gt;&lt;P&gt;Hyundai&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8.000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Hyundai&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8.038&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Hyundai&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7.600&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Jaguar&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20.038&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried it with the following sas code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let period_1=a;
%let period_2=b;
%let period_3=c;
...

%macro test(start=, end=);
       %do i =start %to &amp;amp;end;
              data merge_horizontal;
                  set merge_horizontal;
                      if period= &amp;amp;&amp;amp;period_&amp;amp;i Then car_&amp;amp;&amp;amp;period_&amp;amp;i = car
                      if period= &amp;amp;&amp;amp;period_&amp;amp;i Then value_&amp;amp;&amp;amp;period_&amp;amp;i = value&lt;BR /&gt;                  run;
       %end;
%mend test;&lt;BR /&gt;%test(start=1,&amp;nbsp;end=3);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But it just creates me 2 new collumns (car_c and value_c), doesnt delete the column car and value and is not sorted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you understand what i want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 09:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921269#M362802</guid>
      <dc:creator>MaxiHösi</dc:creator>
      <dc:date>2024-03-21T09:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: "merge" numoerous tables but side by side in a new table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921272#M362804</link>
      <description>Your desired output look more like a report than a dataset/data table.&lt;BR /&gt;Look into PROC REPORT or PROC TABULATE to create your desired layout.</description>
      <pubDate>Thu, 21 Mar 2024 10:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921272#M362804</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2024-03-21T10:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: "merge" numoerous tables but side by side in a new table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921301#M362812</link>
      <description>&lt;P&gt;What i found so far about proc report or proc tabulate is not really what i search. I want to continue working with the output.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 14:21:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921301#M362812</guid>
      <dc:creator>MaxiHösi</dc:creator>
      <dc:date>2024-03-21T14:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: "merge" numoerous tables but side by side in a new table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921307#M362816</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/464508"&gt;@MaxiHösi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What i found so far about proc report or proc tabulate is not really what i search. I want to continue working with the output.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You could not work with a DATASET that looks like that.&lt;/P&gt;
&lt;P&gt;What kind of "work" are you planning to do with that report?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 14:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921307#M362816</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-21T14:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: "merge" numoerous tables but side by side in a new table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921308#M362817</link>
      <description>&lt;P&gt;Use a MERGE with no BY statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge have(rename=(car=carA value=valueA period=periodA) where=(periodA='A'))
        have(rename=(car=carB value=valueB period=periodB) where=(periodB='B'))
        have(rename=(car=carC value=valueC period=periodC) where=(periodC='C'))
 ;
 drop period: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs     carA      valueA     carB      valueB     carC      valueC

 1     Renault    10.002    Renault    11.099    Renault     9.035
 2     Toyota     12.000    Toyota     12.054    Toyota     10.154
 3     Hyundai     8.000    Hyundai     8.038    Hyundai     7.600
 4                  .       Jaguar     20.038                 .
&lt;/PRE&gt;
&lt;P&gt;But it might make more sense if the rows in the resulting table (the observations in the resulting dataset) are aligned by the CAR value.&amp;nbsp; In which case PROC TRANSPOSE would be much easier.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
  by car period;
run;
proc transpose data=have out=wide(drop=_name_) prefix=value;
  by car;
  var value;
  id period;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs      car      valueA    valueB    valueC

 1     Hyundai     8.000     8.038     7.600
 2     Jaguar       .       20.038      .
 3     Renault    10.002    11.099     9.035
 4     Toyota     12.000    12.054    10.154
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 15:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921308#M362817</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-21T15:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: "merge" numoerous tables but side by side in a new table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921310#M362819</link>
      <description>&lt;P&gt;I suggest providing a very clear example of what your next steps you will do with data in that "wide" format would actually be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, I might expect to Merge BY car since you apparently want the same car on a single row. At which point repeated values of Car are next to pretty useless.&lt;/P&gt;
&lt;P&gt;I almost suspect an attempt to mimic a spreadsheet method which a quite often a very poor way to use SAS as the tools are very different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This&amp;nbsp; is the closest I would recommend to actually using. Please not providing your example data in the form of a data step is extremely helpful and may clarify questions (when done properly) that we may have to ask about your variable properties.&lt;/P&gt;
&lt;PRE&gt;data have;
   input Car $    value    period $;
datalines;
Renault       10.002          A
Toyota         12.000         A 
Hyundai      8.000           A
Renault       11.099           B
Toyota         12.054          B 
Hyundai      8.038            B
Jaguar        20.038           B
Renault       9.035             C
Toyota         10.154           C 
Hyundai      7.600            C
;
proc sort data=have;
   by car period;
run;


Proc transpose data=have out=trans (drop=_name_)
   prefix=Value_;
   by car;
   id period;
   var value;
run;

   &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 15:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921310#M362819</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-21T15:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: "merge" numoerous tables but side by side in a new table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921727#M362962</link>
      <description>&lt;P&gt;i tried your solution and it works well. Thank you very much, thats exactly what i wanted &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 18:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921727#M362962</guid>
      <dc:creator>MaxiHösi</dc:creator>
      <dc:date>2024-03-25T18:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: "merge" numoerous tables but side by side in a new table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921728#M362963</link>
      <description>I tried your code and that's exactly what i wanted. Thank you very much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 25 Mar 2024 18:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-merge-quot-numoerous-tables-but-side-by-side-in-a-new-table/m-p/921728#M362963</guid>
      <dc:creator>MaxiHösi</dc:creator>
      <dc:date>2024-03-25T18:05:15Z</dc:date>
    </item>
  </channel>
</rss>

