<?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: Merging data by ID and categorical variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603897#M16996</link>
    <description>&lt;P&gt;select distinct record_id, Category;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you could also add a counter to tell you how many record for each group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Nov 2019 16:09:46 GMT</pubDate>
    <dc:creator>VDD</dc:creator>
    <dc:date>2019-11-13T16:09:46Z</dc:date>
    <item>
      <title>Merging data by ID and categorical variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603894#M16995</link>
      <description>&lt;P&gt;Is it possible to merge multiple observations into one observation based on ID and a categorical variable? Right now I have multiple observations for each record when I only need one observation per record ID for each level of a categorical variable, this is what I need to do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Record ID:&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Category:&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Record ID (grouped):&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Category (grouped):&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1&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; 2&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;1&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; 2&lt;/P&gt;&lt;P&gt;1&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; 2&lt;/P&gt;&lt;P&gt;1&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; 3&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;1&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; 3&lt;/P&gt;&lt;P&gt;1&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; 3&lt;/P&gt;&lt;P&gt;1&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; 3&lt;/P&gt;&lt;P&gt;2&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; 4&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;2&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; 4&lt;/P&gt;&lt;P&gt;2&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; 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I take the first two columns and group them to create the second two columns?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 15:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603894#M16995</guid>
      <dc:creator>marin1hk</dc:creator>
      <dc:date>2019-11-13T15:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Merging data by ID and categorical variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603897#M16996</link>
      <description>&lt;P&gt;select distinct record_id, Category;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you could also add a counter to tell you how many record for each group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 16:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603897#M16996</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-11-13T16:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Merging data by ID and categorical variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603898#M16997</link>
      <description>&lt;P&gt;It really is not clear what your output should be. Is it a report that people read or a data set? If a data set would it have 7 records with missing values for several or 3?&lt;/P&gt;
&lt;P&gt;Also, are there other variables involved?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This may be one way:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table want as
   select distinct recordid, category
   from have;
quit;&lt;/PRE&gt;
&lt;P&gt;Since you don't actually show normally acceptable SAS variable names I'm guessing on those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 16:12:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603898#M16997</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-13T16:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Merging data by ID and categorical variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603901#M16998</link>
      <description>&lt;P&gt;Proc sort using nodukey option might also do what you want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input recordID Category;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2&lt;BR /&gt;1 2&lt;BR /&gt;1 3&lt;BR /&gt;1 3&lt;BR /&gt;1 3&lt;BR /&gt;2 4&lt;BR /&gt;2 4&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data = have nodupkey; by recordID category; run;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 16:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603901#M16998</guid>
      <dc:creator>Bennyboy</dc:creator>
      <dc:date>2019-11-13T16:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merging data by ID and categorical variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603926#M17005</link>
      <description>&lt;P&gt;You have plenty of good suggestions that work for what you have presented.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, suppose your data set contains additional variables and you would like to preserve some values of those other variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a solution that best addresses the issue of "additional variables":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
update have (obs=0) have;
by id category;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Nov 2019 18:37:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merging-data-by-ID-and-categorical-variable/m-p/603926#M17005</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-11-13T18:37:23Z</dc:date>
    </item>
  </channel>
</rss>

