<?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: Error message during concatenation: Variable already exists on file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412222#M100818</link>
    <description>&lt;P&gt;That's the point: one of the original variables (level), is defined as 'Character' in one data set and&amp;nbsp; 'Numeric' in the other data set. That's why I introduced the $ . I did that on purpose to expose the issue described above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 10 Nov 2017 06:19:29 GMT</pubDate>
    <dc:creator>FoxMulder</dc:creator>
    <dc:date>2017-11-10T06:19:29Z</dc:date>
    <item>
      <title>Error message during concatenation: Variable already exists on file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412216#M100815</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been receiving this error message during the concatenation of two files which have a variable with&amp;nbsp; different data types: "Variable Level already exists on file WORK.ALL_PAYS". The outcome of the concatenation is partially OK, since there are some observations (the two ones from the file Pay 1996, variable 'Level') that should have data, but they are actually with missing values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Pay1995;&lt;BR /&gt;Input ID $ 1-3 Level $ 5-7 Salary 9-14 Gender $ 16-17;&lt;BR /&gt;Datalines;&lt;BR /&gt;A23&amp;nbsp; 32&amp;nbsp; 68000&amp;nbsp; M&lt;BR /&gt;A24&amp;nbsp; 35&amp;nbsp;&amp;nbsp; 7500&amp;nbsp; F&lt;BR /&gt;A30&amp;nbsp; 44&amp;nbsp; 97000&amp;nbsp; M&lt;BR /&gt;A13&amp;nbsp; 28&amp;nbsp; 27000&amp;nbsp; F&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Data Pay1996;&lt;BR /&gt;Input ID $ 1-3 Level $ 5-7 Salary 9-14 Gender $ 16-17;&lt;BR /&gt;Datalines;&lt;BR /&gt;A25&amp;nbsp; 29&amp;nbsp; 35000&amp;nbsp; F&lt;BR /&gt;A26&amp;nbsp; 36&amp;nbsp; 88000&amp;nbsp; F&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*To concatenate the two datasets successfully, you need to change the Level variable in one of the data sets so the types match.&lt;BR /&gt;Use either the PUT or INPUT function to modify your variable type.;&lt;BR /&gt;&lt;BR /&gt;Data work.pay1995;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set work.pay1995;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Level2=input(Level,4.);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*Use appropriate DROP and RENAME statements or options to achieve this in ONE DATA step.;&lt;BR /&gt;&lt;BR /&gt;Data work.All_Pays&amp;nbsp; (RENAME=(LEVEL2=Level));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&amp;nbsp;&amp;nbsp; work.Pay1995 (drop =Level) work.Pay1996;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know how can I improve my code and fix the error(s).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 04:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412216#M100815</guid>
      <dc:creator>FoxMulder</dc:creator>
      <dc:date>2017-11-10T04:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Error message during concatenation: Variable already exists on file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412217#M100816</link>
      <description>&lt;P&gt;I guess you meant :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Input ID $ 1-3 Level 5-7 Salary 9-14 Gender $ 16-17;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(without the $) for one of your example datasets.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 05:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412217#M100816</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-11-10T05:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Error message during concatenation: Variable already exists on file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412222#M100818</link>
      <description>&lt;P&gt;That's the point: one of the original variables (level), is defined as 'Character' in one data set and&amp;nbsp; 'Numeric' in the other data set. That's why I introduced the $ . I did that on purpose to expose the issue described above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 06:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412222#M100818</guid>
      <dc:creator>FoxMulder</dc:creator>
      <dc:date>2017-11-10T06:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Error message during concatenation: Variable already exists on file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412224#M100819</link>
      <description>&lt;P&gt;Yes, you right..I have seen you point .I made a mistake...Let me copy the code again:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Pay1995;&lt;BR /&gt;Input ID $ 1-3 Level&amp;nbsp; 5-7 Salary 9-14 Gender $ 16-17;&lt;BR /&gt;Datalines;&lt;BR /&gt;A23&amp;nbsp; 32&amp;nbsp; 68000&amp;nbsp; M&lt;BR /&gt;A24&amp;nbsp; 35&amp;nbsp;&amp;nbsp; 7500&amp;nbsp; F&lt;BR /&gt;A30&amp;nbsp; 44&amp;nbsp; 97000&amp;nbsp; M&lt;BR /&gt;A13&amp;nbsp; 28&amp;nbsp; 27000&amp;nbsp; F&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data Pay1996;&lt;BR /&gt;Input ID $ 1-3 Level $ 5-7 Salary 9-14 Gender $ 16-17;&lt;BR /&gt;Datalines;&lt;BR /&gt;A25&amp;nbsp; 29&amp;nbsp; 35000&amp;nbsp; F&lt;BR /&gt;A26&amp;nbsp; 36&amp;nbsp; 88000&amp;nbsp; F&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*To concatenate the two datasets successfully, you need to change the Level variable in one of the data sets so the types match.&lt;BR /&gt;Use either the PUT or INPUT function to modify your variable type.;&lt;BR /&gt;&lt;BR /&gt;data work.pay1995;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set work.pay1995;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Level2=input(Level,4.);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*Use appropriate DROP and RENAME statements or options to achieve this in ONE DATA step.;&lt;BR /&gt;&lt;BR /&gt;data work.All_Pays&amp;nbsp; (RENAME=(LEVEL2=Level));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&amp;nbsp;&amp;nbsp; work.Pay1995 (drop =Level) work.Pay1996;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the confusion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 06:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412224#M100819</guid>
      <dc:creator>FoxMulder</dc:creator>
      <dc:date>2017-11-10T06:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Error message during concatenation: Variable already exists on file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412226#M100821</link>
      <description>&lt;P&gt;I have changed the code to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Pay1995;&lt;BR /&gt;Input ID $ 1-3 Level $ 5-7 Salary 9-14 Gender $ 16-17;&lt;BR /&gt;Datalines;&lt;BR /&gt;A23&amp;nbsp; 32&amp;nbsp; 68000&amp;nbsp; M&lt;BR /&gt;A24&amp;nbsp; 35&amp;nbsp;&amp;nbsp; 7500&amp;nbsp; F&lt;BR /&gt;A30&amp;nbsp; 44&amp;nbsp; 97000&amp;nbsp; M&lt;BR /&gt;A13&amp;nbsp; 28&amp;nbsp; 27000&amp;nbsp; F&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data Pay1996;&lt;BR /&gt;Input ID $ 1-3 Level&amp;nbsp; 5-7 Salary 9-14 Gender $ 16-17;&lt;BR /&gt;Datalines;&lt;BR /&gt;A25&amp;nbsp; 29&amp;nbsp; 35000&amp;nbsp; F&lt;BR /&gt;A26&amp;nbsp; 36&amp;nbsp; 88000&amp;nbsp; F&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*To concatenate the two datasets successfully, you need to change the Level variable in one of the data sets so the types match.&lt;BR /&gt;Use either the PUT or INPUT function to modify your variable type.;&lt;BR /&gt;&lt;BR /&gt;data work.pay1995;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set work.pay1995;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Level2=input(Level,4.);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*Use appropriate DROP and RENAME statements or options to achieve this in ONE DATA step.;&lt;BR /&gt;&lt;BR /&gt;data work.All_Pays&amp;nbsp; (RENAME=(LEVEL2=Level));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&amp;nbsp;&amp;nbsp; work.Pay1995 (drop =Level) work.Pay1996;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 06:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412226#M100821</guid>
      <dc:creator>FoxMulder</dc:creator>
      <dc:date>2017-11-10T06:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: Error message during concatenation: Variable already exists on file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412227#M100822</link>
      <description>&lt;P&gt;I would concatenate this way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data all;
set 
    pay1995 
    pay1996 (in=in2 rename=level=levelStr);
if in2 then level = input(levelStr, best.);
drop levelStr;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Nov 2017 06:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/412227#M100822</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-11-10T06:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Error message during concatenation: Variable already exists on file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/415736#M102011</link>
      <description>&lt;P&gt;Thank you, your solution solved the problem!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for my late reply&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 05:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-message-during-concatenation-Variable-already-exists-on/m-p/415736#M102011</guid>
      <dc:creator>FoxMulder</dc:creator>
      <dc:date>2017-11-23T05:40:10Z</dc:date>
    </item>
  </channel>
</rss>

