<?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: Merge by date, variable Date has been defined as both character and numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352530#M82191</link>
    <description>&lt;P&gt;Thank you art297, I don't quite understand why we need "??" here.&lt;/P&gt;&lt;PRE&gt; date=input(_date, ?? anydtdte11.);&lt;/PRE&gt;</description>
    <pubDate>Sun, 23 Apr 2017 01:22:02 GMT</pubDate>
    <dc:creator>Xusheng</dc:creator>
    <dc:date>2017-04-23T01:22:02Z</dc:date>
    <item>
      <title>Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352492#M82178</link>
      <description>&lt;P&gt;Hi I'm trying to merge two files by date. However, the date is not matching and after I ran the code the log showed the following warning: "Variable Date has been defined as both character and numeric"&lt;/P&gt;&lt;P&gt;Here is the example of two files:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8494iFC543F9AD81EA2F4/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="CAD (2).png" title="CAD (2).png" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8495i5519FCFB65993517/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Oil_return.png" title="Oil_return.png" /&gt;&lt;/P&gt;&lt;P&gt;Can anyone give some suggestion about how to sovle this problem?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 20:28:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352492#M82178</guid>
      <dc:creator>Xusheng</dc:creator>
      <dc:date>2017-04-22T20:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352493#M82179</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114336"&gt;@Xusheng&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;"Variable Date has been defined as both character and numeric"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Make them both the same type.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally, SAS Dates, which are numeric with a date format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could do this in a join on your SQL condition, but I suggest an intermediate step if you're new to programming and SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use INPUT to convert to numeric.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 20:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352493#M82179</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-22T20:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352508#M82183</link>
      <description>&lt;P&gt;You can convert the character variable to a date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fixed ;
  set have ;
  datenum = input(date,yymmdd10.);
  format datenum yymmdd10.;
  rename datenum=date date=datechar ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it is probably best to fix the underlying problem. &amp;nbsp;For example if you used PROC IMPORT to read your CSV files into datasets you could instead just read the CSV directly your self and have control over how the variables are defined.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cad ;
  input 'cad.csv' dsd firstobs=2 truncover ;
  length date cad 8 ;
  informat date yymmdd.;
  format date yymmdd10.;
  input date cad;
run;

data reutrn;
  input 'return.csv' dsd firstobs=2 truncover ;
  length date return 8 ;
  informat date yymmdd.;
  format date yymmdd10.;
  input date return;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Apr 2017 22:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352508#M82183</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-22T22:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352510#M82184</link>
      <description>&lt;P&gt;I think this is the same question you posted in a different thread. Regardless, if the "ND" values are in the CAD file, and that is why proc import considered it a character field, here is how I would solve it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* The following is simply to replicate what I think you have*/&lt;BR /&gt;data cad;
  informat date $10.;
  informat cad $6.;
  input date cad;
  cards;
2004-01-02 1.29
2004-01-05 1.2803
2004-01-06 1.2824
2004-01-07 1.2824
2004-01-08 1.279
2004-01-09 1.269
ND .
2004-01-12 1.2735
2004-01-13 1.2729
;

data oil;
  informat date yymmdd10.;
  input date price;
  cards;
2004-01-05 33.78
2004-01-06 33.7
2004-01-07 33.62
2004-01-08 33.98
2004-01-09 34.31
;
/* Now here is the proposed solution */&lt;BR /&gt;
data want_cad (drop=_:);
  format date date9.;
  set cad (rename=(date=_date cad=_cad));
  date=input(_date, ?? anydtdte11.);
  cad=input(_cad,8.);
  if not missing(cad);
run;

data want;
  merge want_cad (in=ina) oil (in=inb);
  by date;
  if ina and inb;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 22:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352510#M82184</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-22T22:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352516#M82186</link>
      <description>&lt;P&gt;Thank you Reeza, I will try this&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 23:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352516#M82186</guid>
      <dc:creator>Xusheng</dc:creator>
      <dc:date>2017-04-22T23:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352529#M82190</link>
      <description>&lt;P&gt;Thkank you, I don't quite understand the&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token string"&gt;'cad.csv'&lt;/SPAN&gt; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Should this be the path? &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 01:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352529#M82190</guid>
      <dc:creator>Xusheng</dc:creator>
      <dc:date>2017-04-23T01:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352530#M82191</link>
      <description>&lt;P&gt;Thank you art297, I don't quite understand why we need "??" here.&lt;/P&gt;&lt;PRE&gt; date=input(_date, ?? anydtdte11.);&lt;/PRE&gt;</description>
      <pubDate>Sun, 23 Apr 2017 01:22:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352530#M82191</guid>
      <dc:creator>Xusheng</dc:creator>
      <dc:date>2017-04-23T01:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352532#M82192</link>
      <description>&lt;P&gt;As I recall you had some date fields that contained the characters "ND" or some set of two characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The ?? in the input function basically tell SAS to not treat such fields as an error (and stop processing) but, rather, simply set the field to missing and continue processing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 01:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352532#M82192</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-23T01:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352601#M82215</link>
      <description>&lt;P&gt;Thank you art297, I understand now.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 16:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352601#M82215</guid>
      <dc:creator>Xusheng</dc:creator>
      <dc:date>2017-04-23T16:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352602#M82216</link>
      <description>&lt;P&gt;Yes. You need to tell the INPUT statement where to find your data file.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 16:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352602#M82216</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-23T16:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352607#M82217</link>
      <description>&lt;P&gt;thank you, that's what I thought. However, the log gives the following error:&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8502i6D382D54DAA9C84F/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="error.png" title="error.png" /&gt;&lt;/P&gt;&lt;P&gt;any suggestion about this problem?&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 16:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352607#M82217</guid>
      <dc:creator>Xusheng</dc:creator>
      <dc:date>2017-04-23T16:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352624#M82219</link>
      <description>&lt;P&gt;Your code is incorrect.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The log tells you the issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No datalines or infile statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This error has no bearing on your original question however and is an issue with incorrect code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to manually read your files you need the correct statements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://stats.idre.ucla.edu/sas/faq/how-do-i-read-in-a-delimited-ascii-file-in-sas/" target="_blank"&gt;http://stats.idre.ucla.edu/sas/faq/how-do-i-read-in-a-delimited-ascii-file-in-sas/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please read the entire page, it covers many different scenarios and yours is included.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 18:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352624#M82219</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-23T18:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Merge by date, variable Date has been defined as both character and numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352636#M82226</link>
      <description>&lt;P&gt;Thank you, I'll read it&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 19:51:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-by-date-variable-Date-has-been-defined-as-both-character/m-p/352636#M82226</guid>
      <dc:creator>Xusheng</dc:creator>
      <dc:date>2017-04-23T19:51:27Z</dc:date>
    </item>
  </channel>
</rss>

