<?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: Variable has been defined as both character and numeric in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Variable-has-been-defined-as-both-character-and-numeric/m-p/50200#M13655</link>
    <description>A few items to correct and some suggestions:&lt;BR /&gt;
&lt;BR /&gt;
1) Your IF statement must follow the SET statement.&lt;BR /&gt;
2) The correct method to code a date-literal requires you specify a trailing "D" character after the quoted string -- such as '01jan2009'd.&lt;BR /&gt;
3) Suggestion: move your FORMAT statement to be in the DATA step where you are transforming the "purpose" of BDATE - from a DATETIME variable to a DATE (numeric) variable, mostly for relevance.&lt;BR /&gt;
4) Suggestion: remove the redundant OPTIONS COMPRESS=YES;   statement -- that CONFIG option had already been set with the first statement.&lt;BR /&gt;
5) Suggestion (depending on your data-volume) either change the IF statement to a WHERE statement or also consider using a PROC FORMAT to accomplish your look-up / data-filtering processing for optimized performance.&lt;BR /&gt;
6) Suggestion: explore the use of SAS views (or an index) for further performance optimization, where applicable.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Tue, 30 Jun 2009 15:50:03 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-06-30T15:50:03Z</dc:date>
    <item>
      <title>ERROR: Variable has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Variable-has-been-defined-as-both-character-and-numeric/m-p/50199#M13654</link>
      <description>Hello, I know that this has to be an easy fix for you savvy SAS users;&lt;BR /&gt;
I formatted the date from generic SAS datetime to this: &lt;BR /&gt;
&lt;BR /&gt;
DATA V_DATE; SET CERTS; BDATE=DATEPART(BDATE); RUN;&lt;BR /&gt;
PROC SORT DATA=V_DATE; BY BDATE; FORMAT BDATE mmddyy10.; RUN; OPTIONS COMPRESS=YES; RUN;&lt;BR /&gt;
&lt;BR /&gt;
And now when I try to search for specific dates within V_DATE it tells me that BDATE has been defined as both character and numeric, although when I do a proc contents it tells me it is numeric.&lt;BR /&gt;
&lt;BR /&gt;
DATA MISSING; IF BDATE IN(&lt;BR /&gt;
'01/22/2006'&lt;BR /&gt;
'02/14/2006'&lt;BR /&gt;
'02/21/2006'&lt;BR /&gt;
'03/05/2006'&lt;BR /&gt;
'03/17/2006'&lt;BR /&gt;
'03/18/2006'&lt;BR /&gt;
'03/19/2006'&lt;BR /&gt;
'03/24/2006'&lt;BR /&gt;
'04/24/2006'&lt;BR /&gt;
'05/08/2006'&lt;BR /&gt;
'05/30/2006'&lt;BR /&gt;
'06/12/2006'&lt;BR /&gt;
'06/13/2006'&lt;BR /&gt;
'06/17/2006'&lt;BR /&gt;
'07/26/2006'&lt;BR /&gt;
'09/28/2006'&lt;BR /&gt;
'10/06/2006'&lt;BR /&gt;
'10/23/2006'&lt;BR /&gt;
'12/11/2006'&lt;BR /&gt;
'12/18/2006'&lt;BR /&gt;
'12/31/2006'&lt;BR /&gt;
'01/04/2007'&lt;BR /&gt;
'01/17/2007'&lt;BR /&gt;
'01/26/2007'&lt;BR /&gt;
'02/14/2007'&lt;BR /&gt;
'05/16/2007'&lt;BR /&gt;
'05/30/2007'&lt;BR /&gt;
'07/18/2007'&lt;BR /&gt;
'07/19/2007'&lt;BR /&gt;
'08/15/2007'&lt;BR /&gt;
'10/04/2007'&lt;BR /&gt;
'10/05/2007'&lt;BR /&gt;
'10/24/2007'&lt;BR /&gt;
'11/08/2007'&lt;BR /&gt;
'12/26/2007'); SET V_DATE;OPTIONS COMPRESS=YES; RUN; &lt;BR /&gt;
&lt;BR /&gt;
It tells me this:  Variable BDATE has been defined as both character and numeric.&lt;BR /&gt;
&lt;BR /&gt;
grrrrrrr!!!! HELP &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ?</description>
      <pubDate>Tue, 30 Jun 2009 15:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Variable-has-been-defined-as-both-character-and-numeric/m-p/50199#M13654</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-30T15:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Variable has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Variable-has-been-defined-as-both-character-and-numeric/m-p/50200#M13655</link>
      <description>A few items to correct and some suggestions:&lt;BR /&gt;
&lt;BR /&gt;
1) Your IF statement must follow the SET statement.&lt;BR /&gt;
2) The correct method to code a date-literal requires you specify a trailing "D" character after the quoted string -- such as '01jan2009'd.&lt;BR /&gt;
3) Suggestion: move your FORMAT statement to be in the DATA step where you are transforming the "purpose" of BDATE - from a DATETIME variable to a DATE (numeric) variable, mostly for relevance.&lt;BR /&gt;
4) Suggestion: remove the redundant OPTIONS COMPRESS=YES;   statement -- that CONFIG option had already been set with the first statement.&lt;BR /&gt;
5) Suggestion (depending on your data-volume) either change the IF statement to a WHERE statement or also consider using a PROC FORMAT to accomplish your look-up / data-filtering processing for optimized performance.&lt;BR /&gt;
6) Suggestion: explore the use of SAS views (or an index) for further performance optimization, where applicable.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 30 Jun 2009 15:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Variable-has-been-defined-as-both-character-and-numeric/m-p/50200#M13655</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-30T15:50:03Z</dc:date>
    </item>
  </channel>
</rss>

