<?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 Creat additional columns to avoid duplicate data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421650#M280837</link>
    <description>&lt;P&gt;Hi, I have a dataset that is duplicating data from two&amp;nbsp;rows if there is more than one variable in the final column like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;fruit&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; quality&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;banana&amp;nbsp; &amp;nbsp; &amp;nbsp; yellow&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;apple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;green&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;apple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;round&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I Want is for each row to be unique like below, such that if the quality column has multiple entries, it will create a new column and insert it there - column_2, column_3, column_4 and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;fruit&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;quality_1&amp;nbsp; &amp;nbsp; Quality_2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; banana&amp;nbsp; &amp;nbsp; &amp;nbsp; yellow&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; apple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;green&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; round&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have looked around the forum and some text books looking for an answer to this and&amp;nbsp;haven't found much&amp;nbsp;- any help would be appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Dec 2017 17:09:55 GMT</pubDate>
    <dc:creator>andrewjason</dc:creator>
    <dc:date>2017-12-15T17:09:55Z</dc:date>
    <item>
      <title>Creat additional columns to avoid duplicate data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421650#M280837</link>
      <description>&lt;P&gt;Hi, I have a dataset that is duplicating data from two&amp;nbsp;rows if there is more than one variable in the final column like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;fruit&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; quality&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;banana&amp;nbsp; &amp;nbsp; &amp;nbsp; yellow&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;apple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;green&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;apple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;round&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I Want is for each row to be unique like below, such that if the quality column has multiple entries, it will create a new column and insert it there - column_2, column_3, column_4 and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;fruit&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;quality_1&amp;nbsp; &amp;nbsp; Quality_2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; banana&amp;nbsp; &amp;nbsp; &amp;nbsp; yellow&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; apple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;green&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; round&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have looked around the forum and some text books looking for an answer to this and&amp;nbsp;haven't found much&amp;nbsp;- any help would be appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 17:09:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421650#M280837</guid>
      <dc:creator>andrewjason</dc:creator>
      <dc:date>2017-12-15T17:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creat additional columns to avoid duplicate data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421653#M280838</link>
      <description>&lt;P&gt;Have you looked at PROC TRANSPOSE? That works fine for me and generates the output you indicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="delete_transpose.JPG" style="width: 580px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17339iAEB10A0B146A1EE0/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_transpose.JPG" alt="delete_transpose.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/182797"&gt;@andrewjason&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I have a dataset that is duplicating data from two&amp;nbsp;rows if there is more than one variable in the final column like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp;fruit&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; quality&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;banana&amp;nbsp; &amp;nbsp; &amp;nbsp; yellow&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;apple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;green&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;apple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;round&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I Want is for each row to be unique like below, such that if the quality column has multiple entries, it will create a new column and insert it there - column_2, column_3, column_4 and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp;fruit&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;quality_1&amp;nbsp; &amp;nbsp; Quality_2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; banana&amp;nbsp; &amp;nbsp; &amp;nbsp; yellow&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; apple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;green&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; round&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have looked around the forum and some text books looking for an answer to this and&amp;nbsp;haven't found much&amp;nbsp;- any help would be appreciated. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 17:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421653#M280838</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-15T17:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creat additional columns to avoid duplicate data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421654#M280839</link>
      <description>&lt;P&gt;That is called transposing data from long to wide. Proc transpose will do this is SAS.&lt;/P&gt;
&lt;P&gt;For almost every purpose processing is easier in the long form.&lt;/P&gt;
&lt;P&gt;Example: if both Apple and Banana have the quality of "sweet" there is no way to ensure that Sweet is in the same quality variable so you spend lots of time having to search through many variables for everything done later on. And if you later have another data set to combine the quality value for Apple is very likely to appear in a different variable for the same value and the number of quality variables may change. Which complicates all of those searches through multiple variables to determine if "sweet" is one of the qualities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sort the data by Id fruit.&lt;/P&gt;
&lt;P&gt;Then&lt;/P&gt;
&lt;P&gt;Proc transpose data=have out=want prefix=quanlity_;&lt;/P&gt;
&lt;P&gt;by id fruit;&lt;/P&gt;
&lt;P&gt;var quality;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 18:25:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421654#M280839</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-15T18:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creat additional columns to avoid duplicate data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421659#M280840</link>
      <description>This is great! thanks!</description>
      <pubDate>Fri, 15 Dec 2017 17:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421659#M280840</guid>
      <dc:creator>andrewjason</dc:creator>
      <dc:date>2017-12-15T17:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creat additional columns to avoid duplicate data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421660#M280841</link>
      <description>&lt;P&gt;Great Explanation! Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 17:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creat-additional-columns-to-avoid-duplicate-data/m-p/421660#M280841</guid>
      <dc:creator>andrewjason</dc:creator>
      <dc:date>2017-12-15T17:34:43Z</dc:date>
    </item>
  </channel>
</rss>

