<?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: ID is has been defined as both character and numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402900#M97878</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139341"&gt;@kmardinian&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;What's strange is the ID in both excel sheets are in the exact same format. The cells are formatted as "General" and the ID numbers are all 8 numbers long. So I'm not sure why SAS is reading them as different?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;PROC IMPORT doesn't do a great job at reading data from Excel. If you can, consider using a text file, csv, instead. Then you can specify the types. Excel doesn't enforce types so it's not a good medium for storing and transferring data.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 19:07:07 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-10-10T19:07:07Z</dc:date>
    <item>
      <title>ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402872#M97865</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=&amp;nbsp;G out=G1;&lt;BR /&gt;by ID;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=&amp;nbsp;P out=P1;&lt;BR /&gt;by ID;&lt;BR /&gt;run;&lt;BR /&gt;Proc sort data=T out=T1;&lt;BR /&gt;by ID;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;Data CombinedData;&lt;BR /&gt;Merge&amp;nbsp;G1&amp;nbsp;P1;&lt;BR /&gt;By ID;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;Data MCC1;&lt;BR /&gt;Set CombinedData (keep= Name&amp;nbsp;ID&amp;nbsp;protocol);&lt;BR /&gt;If missing(protocol) then delete;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Data T1;&lt;/P&gt;&lt;P&gt;IDchar = put(ID, $8.);&lt;BR /&gt;drop ID;&lt;BR /&gt;rename IDchar=ID;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;Data BT;&lt;BR /&gt;Merge T1 MCC1;&lt;BR /&gt;By ID Name;&lt;BR /&gt;If inT1 and inMCC1;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code above, I've been getting this error for the ID variable where SAS states that it is not defined as character or numeric, so I added in a part of the code above to try to transform the ID variable (&lt;SPAN&gt;IDchar = put(ID, $8.);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;drop ID;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;rename IDchar=ID;)&lt;/SPAN&gt;. But now my Data BT just shows up blank and no observations are printed or read through SAS. Any help is much appreciated, I am still pretty new to SAS. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 17:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402872#M97865</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T17:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402878#M97868</link>
      <description>&lt;P&gt;Verify that your INPUT() conversion worked correctly. I suspect it didn't.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 17:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402878#M97868</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-10T17:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402880#M97869</link>
      <description>&lt;P&gt;I used proc import to import the excel datasets and they seem to have imported correctly.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 17:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402880#M97869</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T17:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402881#M97870</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Data BT;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Merge T1 MCC1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;By ID Name;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;If inT1 and inMCC1;&lt;/STRONG&gt; &lt;/FONT&gt;*&amp;lt;- this line is incorrect, you have no variables created with these names;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 17:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402881#M97870</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-10T17:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402882#M97871</link>
      <description>&lt;P&gt;I see, I assumed sas would pull the variables from the excel spreadsheet. What would be the easiest way to do that? Should I use a Keep statement when merging the two datasets?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 17:56:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402882#M97871</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T17:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402883#M97872</link>
      <description>&lt;P&gt;Let's narrow down the problem a little.&amp;nbsp; Are these the right issues?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You have an existing data set named T1, that contains a numeric variable named ID.&lt;/LI&gt;
&lt;LI&gt;To be able to merge with other data sets, you need to change ID to character (within the T1 data set).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Does that sound about right?&amp;nbsp; If so ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, note that your existing data step that re-generates T1 does not contain a SET statement.&amp;nbsp; Where is the data supposed to come from?&amp;nbsp; You might need:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data T1;&lt;/P&gt;
&lt;P&gt;set T1&lt;/P&gt;
&lt;P&gt;IDchar = .......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, one of these formulas would be better:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IDchar = put(ID, z8.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or possibly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IDchar = put(ID, 8.);&lt;/P&gt;
&lt;P&gt;IDchar = left(IDchar);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might have to see what ID looks like within MCC1 to determine which of these makes sense.&amp;nbsp; Whichever one looks right, you still need your DROP and RENAME statements.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 17:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402883#M97872</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-10T17:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402886#M97873</link>
      <description>&lt;P&gt;Data T2;&lt;BR /&gt;Set T1 (keep=&amp;nbsp;ID&amp;nbsp;Name);&lt;BR /&gt;IDchar = put(ID, z8.);&lt;BR /&gt;drop ID;&lt;BR /&gt;rename IDchar=ID;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;Data BT (keep= ID&amp;nbsp;Name);&lt;BR /&gt;Merge T2 MCC1;&lt;BR /&gt;By ID;&lt;BR /&gt;*If inT2 and inMCC1;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So adding in the set statement I think worked! But it did give me a warning saying "&lt;SPAN&gt;WARNING: Variable MRN has already been defined as numeric." Does that still mean it's ok?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But now I have also another issue, when I merge T2 and MCC1 to create the dataset BT, I lose the ID the Names from MCC1...I took out my "if inT2 and inMCC1" statement for now because it is still giving me errors&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 18:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402886#M97873</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T18:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402887#M97874</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139341"&gt;@kmardinian&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So adding in the set statement I think worked! But it did give me a warning saying "&lt;SPAN&gt;WARNING: Variable MRN has already been defined as numeric." Does that still mean it's ok?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But now I have also another issue, when I merge T2 and MCC1 to create the dataset BT, I lose the ID the Names from MCC1...I took out my "if inT2 and inMCC1" statement for now because it is still giving me errors&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, it's not ok. You can use the log to find syntax errors, but you need to confirm your data meets what you expect by examining the data. We can't really tell you what's correct or not logically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 18:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402887#M97874</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-10T18:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402889#M97875</link>
      <description>&lt;P&gt;LOG:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;61&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;62&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;63 Data T2;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;64 Set T1 (keep=&amp;nbsp;ID&amp;nbsp;Name);&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;65 IDchar = put(ID, z8.);&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: Variable&amp;nbsp;ID has already been defined as numeric.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;66 drop ID;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;67 rename IDchar=ID;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;68 Run;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: There were 26932 observations read from the data set WORK.T1.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The data set WORK.T2 has 26932 observations and 2 variables.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.01 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.01 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;69&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;70&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;71 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;84&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;The Log isn't giving me too much information, so it probably didn't work in fixing this issue. I'm not really sure what next steps to take&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 Oct 2017 18:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402889#M97875</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T18:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402890#M97876</link>
      <description>&lt;P&gt;What's strange is the ID in both excel sheets are in the exact same format. The cells are formatted as "General" and the ID numbers are all 8 numbers long. So I'm not sure why SAS is reading them as different?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 18:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402890#M97876</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T18:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402892#M97877</link>
      <description>&lt;P&gt;If I were to change ID to just be read as character, where would it best to write that code?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 18:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402892#M97877</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T18:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402900#M97878</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139341"&gt;@kmardinian&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;What's strange is the ID in both excel sheets are in the exact same format. The cells are formatted as "General" and the ID numbers are all 8 numbers long. So I'm not sure why SAS is reading them as different?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;PROC IMPORT doesn't do a great job at reading data from Excel. If you can, consider using a text file, csv, instead. Then you can specify the types. Excel doesn't enforce types so it's not a good medium for storing and transferring data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 19:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402900#M97878</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-10T19:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: ID is has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402912#M97882</link>
      <description>&lt;P&gt;Ok, thank you! I was able to get it to work.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 19:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-ID-is-has-been-defined-as-both-character-and-numeric/m-p/402912#M97882</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T19:31:35Z</dc:date>
    </item>
  </channel>
</rss>

