<?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: Duplicate errors with Proc Transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-errors-with-Proc-Transpose/m-p/745245#M233573</link>
    <description>&lt;P&gt;Yes, that is what I had in mind&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jun 2021 17:12:37 GMT</pubDate>
    <dc:creator>mreynaud</dc:creator>
    <dc:date>2021-06-02T17:12:37Z</dc:date>
    <item>
      <title>Duplicate errors with Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-errors-with-Proc-Transpose/m-p/745056#M233507</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've been exploring proc transpose and want a narrow data set to become wide. I've been working with a data set and running into an error. For the sake of this example I will use data from sashelp.cars&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create columns with the name of each country from origin and then the make of the cars as the observations under each country.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run this code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test as
select distinct 
	Origin,
	Make
from sashelp.cars;
quit;

proc sort data=test out=test_sort;
by origin;
run;

proc transpose data=test_sort
			   out=test_transp
			   name=column_that_was_transposed;
id origin;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I receive this error:&amp;nbsp;ERROR: The ID value "Asia" occurs twice in the input data set.&lt;/P&gt;&lt;P&gt;To combat it I added a nodupkey option in the proc sort step:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test as
select distinct 
	Origin,
	Make
from sashelp.cars;
quit;

proc sort data=test out=test_sort nodupkey;
by origin;
run;

proc transpose data=test_sort
			   out=test_transp
			   name=column_that_was_transposed;
id origin;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It runs but the table has no observations. Any help would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 22:34:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Duplicate-errors-with-Proc-Transpose/m-p/745056#M233507</guid>
      <dc:creator>mreynaud</dc:creator>
      <dc:date>2021-06-01T22:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate errors with Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-errors-with-Proc-Transpose/m-p/745059#M233508</link>
      <description>&lt;P&gt;What are you expecting?&lt;BR /&gt;Do you want each variable to be the origin and then a list of models underneath like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Asia&amp;nbsp;   |Europe&amp;nbsp;      |USA
---------------------------------
Acura&amp;nbsp; |Audi           |Buick
Honda  |BMW            |Cadillac&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 22:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Duplicate-errors-with-Proc-Transpose/m-p/745059#M233508</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-01T22:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate errors with Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-errors-with-Proc-Transpose/m-p/745060#M233509</link>
      <description>&lt;P&gt;You might show what you expect or want the output to look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run your code this the LOG from the Transpose step:&lt;/P&gt;
&lt;PRE&gt;320  proc transpose data=test_sort
321              out=test_transp
322              name=column_that_was_transposed
323
324  ;
325  id origin;
326  run;

&lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;NOTE: No variables to transpose.&lt;/STRONG&gt;&lt;/FONT&gt;
NOTE: There were 3 observations read from the data set WORK.TEST_SORT.
NOTE: The data set WORK.TEST_TRANSP has 0 observations and 4 variables.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds

&lt;/PRE&gt;
&lt;P&gt;If you do not supply one or more variables on a VAR statement in Proc Transpose then the procedure assumes you want to transpose all of the numeric variables. Since your data set has no numeric variables there is nothing to transpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run&lt;/P&gt;
&lt;PRE&gt;proc transpose data=test_sort
			   out=test_transp
			   name=column_that_was_transposed 
  
;
var make;
id origin;
run;&lt;/PRE&gt;
&lt;P&gt;then you will get one "make" value for each ID variable value in the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you actually need a data set? You might try adding a dummy variable to use as a "by" variable to get around the multiple ID values.&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table test as
select distinct 
	Origin,
	Make

from sashelp.cars;
quit;

data test_dummy;
  set test;
  by origin;
  if first.origin then dummy=1;
  else dummy+1;
run;

proc sort data=test_dummy;
   by dummy origin;
run;


proc transpose data=test_dummy
			   out=test_transp
			   name=column_that_was_transposed 
  
;
by dummy;
var make;
id origin;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Jun 2021 22:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Duplicate-errors-with-Proc-Transpose/m-p/745060#M233509</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-01T22:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate errors with Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-errors-with-Proc-Transpose/m-p/745245#M233573</link>
      <description>&lt;P&gt;Yes, that is what I had in mind&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 17:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Duplicate-errors-with-Proc-Transpose/m-p/745245#M233573</guid>
      <dc:creator>mreynaud</dc:creator>
      <dc:date>2021-06-02T17:12:37Z</dc:date>
    </item>
  </channel>
</rss>

