<?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: Help Transposing a Column with Duplicate Values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/956418#M373485</link>
    <description>Please refer the solution below .&lt;BR /&gt;&lt;BR /&gt;Proc transpose data=final out=a;&lt;BR /&gt;by phone_type;&lt;BR /&gt;var phone number;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Proc transpose data=a out=b (drop-_name_) ;&lt;BR /&gt;var coll col2 col3 col4&amp;gt;&amp;gt;add all colums created;&lt;BR /&gt;id phone type;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;If any doubts plz reach out me on LinkedIn &lt;A href="http://linkedin.com/in/mayur-chaudhari-77010821b" target="_blank"&gt;http://linkedin.com/in/mayur-chaudhari-77010821b&lt;/A&gt;</description>
    <pubDate>Fri, 17 Jan 2025 14:26:13 GMT</pubDate>
    <dc:creator>MayurChaudhari</dc:creator>
    <dc:date>2025-01-17T14:26:13Z</dc:date>
    <item>
      <title>Help Transposing a Column with Duplicate Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/782333#M249392</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table below is what I currently have. Lets call it "Test" for this example&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-11-24_13-16-52.png" style="width: 468px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66087i6D3E41746199F698/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-11-24_13-16-52.png" alt="2021-11-24_13-16-52.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I want is to transpose the phone_type column and have its values contain the phone numbers from the phone_number column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the ideal table I want, we'll call it "Final"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-11-24_13-17-08.png" style="width: 472px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66090iCD206D715D5F7FC7/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-11-24_13-17-08.png" alt="2021-11-24_13-17-08.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been trying the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc transpose data=final out=test;
id phone_type;
var phone_number;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And get this error:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR: The ID value "Home" occurs twice in the input data set.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Any help I can get would be wonderful!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 21:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/782333#M249392</guid>
      <dc:creator>mreynaud</dc:creator>
      <dc:date>2021-11-24T21:26:32Z</dc:date>
    </item>
    <item>
      <title>Difficulty Transposing Columns with Duplicate values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/782318#M249395</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a table called "Final" that will look like this (for this example I am using made up data):&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Client_ID&lt;/TD&gt;&lt;TD&gt;Client_Name&lt;/TD&gt;&lt;TD&gt;Cell&lt;/TD&gt;&lt;TD&gt;Home&lt;/TD&gt;&lt;TD&gt;Text Message Opt-in&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Kate&lt;/TD&gt;&lt;TD&gt;(111)111-1111&lt;/TD&gt;&lt;TD&gt;(101)010-1010&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Jack&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;(202) 020-2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Shannon&lt;/TD&gt;&lt;TD&gt;(333)333-3333&lt;/TD&gt;&lt;TD&gt;(303)030-3030&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;John&lt;/TD&gt;&lt;TD&gt;(444)444-4444&lt;/TD&gt;&lt;TD&gt;(404) 040-4040&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;Juliet&lt;/TD&gt;&lt;TD&gt;(555)555-5555&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;Sayid&lt;/TD&gt;&lt;TD&gt;(666)666-6666&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;Claire&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;(707) 070-7070&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;Alex&lt;/TD&gt;&lt;TD&gt;(888)888-8888&lt;/TD&gt;&lt;TD&gt;(808) 080-8080&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;Charlie&lt;/TD&gt;&lt;TD&gt;(999)999-9999&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table I am working from is called "Test". I've been trying to use Proc Transpose for the columns Phone_Type to create two new columns. The two new columns would be Home and Cell and its values would contain the numbers from the Phone_Number column.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Client_ID&lt;/TD&gt;&lt;TD&gt;Client_Name&lt;/TD&gt;&lt;TD&gt;Phone_Type&lt;/TD&gt;&lt;TD&gt;Phone_Number&lt;/TD&gt;&lt;TD&gt;Text Message Opt-in&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Kate&lt;/TD&gt;&lt;TD&gt;Cell&lt;/TD&gt;&lt;TD&gt;(111)111-1111&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt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;TD&gt;Sayid&lt;/TD&gt;&lt;TD&gt;Cell&lt;/TD&gt;&lt;TD&gt;(666)666-6666&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;Claire&lt;/TD&gt;&lt;TD&gt;Home&lt;/TD&gt;&lt;TD&gt;(707) 070-7070&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;Alex&lt;/TD&gt;&lt;TD&gt;Cell&lt;/TD&gt;&lt;TD&gt;(888)888-8888&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;Alex&lt;/TD&gt;&lt;TD&gt;Home&lt;/TD&gt;&lt;TD&gt;(808) 080-8080&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;Charlie&lt;/TD&gt;&lt;TD&gt;Cell&lt;/TD&gt;&lt;TD&gt;(999)999-9999&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I've been attempting to use&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc transpose data=final out=test;
id phone_type;
var phone_number;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I keep on getting an error that says the ID value "Home" occurs twice in the input data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help I can get would be wonderful!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 21:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/782318#M249395</guid>
      <dc:creator>mreynaud</dc:creator>
      <dc:date>2021-11-24T21:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transposing a Column with Duplicate Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/782339#M249393</link>
      <description>&lt;P&gt;Add&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;by client_id client_name;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to the TRANSPOSE procedure.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 21:39:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/782339#M249393</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-24T21:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transposing a Column with Duplicate Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/782341#M249394</link>
      <description>&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=test out=final;
    by client_id client_name;
    var phone_number;
    id phone_type;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since we can't program from screen captures, we request that in the future you provide data as SAS data steps (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;instructions&lt;/A&gt;) and then we can give you tested code. So, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/364706"&gt;@mreynaud&lt;/a&gt; , please, no more data as screen captures (and also do not provide data as file attachments, as many people will not download them), data only as SAS data steps.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 21:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/782341#M249394</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-24T21:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transposing a Column with Duplicate Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/956417#M373484</link>
      <description />
      <pubDate>Fri, 17 Jan 2025 14:15:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/956417#M373484</guid>
      <dc:creator>MayurChaudhari</dc:creator>
      <dc:date>2025-01-17T14:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transposing a Column with Duplicate Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/956418#M373485</link>
      <description>Please refer the solution below .&lt;BR /&gt;&lt;BR /&gt;Proc transpose data=final out=a;&lt;BR /&gt;by phone_type;&lt;BR /&gt;var phone number;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Proc transpose data=a out=b (drop-_name_) ;&lt;BR /&gt;var coll col2 col3 col4&amp;gt;&amp;gt;add all colums created;&lt;BR /&gt;id phone type;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;If any doubts plz reach out me on LinkedIn &lt;A href="http://linkedin.com/in/mayur-chaudhari-77010821b" target="_blank"&gt;http://linkedin.com/in/mayur-chaudhari-77010821b&lt;/A&gt;</description>
      <pubDate>Fri, 17 Jan 2025 14:26:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/956418#M373485</guid>
      <dc:creator>MayurChaudhari</dc:creator>
      <dc:date>2025-01-17T14:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help Transposing a Column with Duplicate Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/956502#M373501</link>
      <description>&lt;P&gt;I don't see the need for proc transpose here, since a self_merge of the dataset (merging cell phone records against corresponding home phone records) should do well:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge have (where=(phone_type='Cell') rename=(phone_number=cell))
        have (where=(phone_type='Home') rename=(phone_number=home) drop=text_msg_opt);
  by clientid client_name;
  drop phone_type;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program is untested in the absence of sample data in the form of a working DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it will correctly produce the "test_message_opt_in" column, unlike the PROC TRANSPOSE solutions.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2025 19:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Transposing-a-Column-with-Duplicate-Values/m-p/956502#M373501</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2025-01-18T19:45:46Z</dc:date>
    </item>
  </channel>
</rss>

