<?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: Joining Tables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Joining-Tables/m-p/805133#M33454</link>
    <description>&lt;P&gt;Your expected result looks more like a report than a dataset. What should differentiate the multiple values for a given name and year?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2022 19:45:28 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-03-30T19:45:28Z</dc:date>
    <item>
      <title>Joining Tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Joining-Tables/m-p/805131#M33452</link>
      <description>I’m fairly new to SAS but I have a dataset that looks like this:&lt;BR /&gt;&lt;BR /&gt;Name 2020 2021 2022&lt;BR /&gt;A 3 74 72&lt;BR /&gt;A 45 21 5&lt;BR /&gt;A 4 9 10&lt;BR /&gt;&lt;BR /&gt;There is much more data (names and years I would like for the column variables to repeat and all fall under one line.&lt;BR /&gt;&lt;BR /&gt;So:&lt;BR /&gt;&lt;BR /&gt;Name 2020 2021 2022 2020 2021&lt;BR /&gt;A. 3 74. 72. 45. 21&lt;BR /&gt;&lt;BR /&gt;Continued</description>
      <pubDate>Wed, 30 Mar 2022 19:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Joining-Tables/m-p/805131#M33452</guid>
      <dc:creator>Ryan199900</dc:creator>
      <dc:date>2022-03-30T19:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Joining-Tables/m-p/805132#M33453</link>
      <description>&lt;P&gt;You can't have a SAS data set that looks like the one you say you have, because column names cannot begin with a digit. For your output data set, you can't have the same name appear twice (or more than twice) in your list of variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you have presented a problem that can't be accomplished in SAS ... perhaps you could re-state the problem such that it is possible to do in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, since you are new at SAS, re-arranging the data like this, with calendar information in the variable names, is almost always a bad idea. What are you going to do with this data once it is re-arranged? What analysis or report or table will you create?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 19:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Joining-Tables/m-p/805132#M33453</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-30T19:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Joining-Tables/m-p/805133#M33454</link>
      <description>&lt;P&gt;Your expected result looks more like a report than a dataset. What should differentiate the multiple values for a given name and year?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 19:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Joining-Tables/m-p/805133#M33454</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-30T19:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Joining-Tables/m-p/805135#M33455</link>
      <description>&lt;P&gt;Hard to tell what you are trying to do.&amp;nbsp; I sounds like you want to produce a REPORT that looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-03-30 154839.jpg" style="width: 511px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69986iAEED45D81F1D083E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-03-30 154839.jpg" alt="Screenshot 2022-03-30 154839.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Which is easy if you organize your data in the right way with a variables for NAME, YEAR, ROW (or repetition) and VALUE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have;
  column name value,row,year;
  define name / group;
  define row / across ' ';
  define year / across ' ';
  define value / sum ' ';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could build such a dataset from your original listing easily.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input name $ @;
  row+1;
  do year=2020, 2021, 2022;
    input value @;
    output;
  end;
cards;
A 3 74 72
A 45 21 5
A 4 9 10
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example data&lt;/P&gt;
&lt;PRE&gt;Obs    name    row    year    value

 1      A       1     2020       3
 2      A       1     2021      74
 3      A       1     2022      72
 4      A       2     2020      45
 5      A       2     2021      21
 6      A       2     2022       5
 7      A       3     2020       4
 8      A       3     2021       9
 9      A       3     2022      10

&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Mar 2022 19:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Joining-Tables/m-p/805135#M33455</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-30T19:52:10Z</dc:date>
    </item>
  </channel>
</rss>

