<?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: Expression using greater than (&amp;gt;) has components that are of different data types in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expression-using-greater-than-gt-has-components-that-are/m-p/618738#M181548</link>
    <description>&lt;P&gt;Birthdate is a numeric variable but you are comparing it to a character string - '01/01/2001'. Changing your WHERE clause to use a date constant like so should fix your error:&lt;/P&gt;
&lt;PRE&gt;WHERE Birthdate &amp;gt; '01Dec2001'd&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jan 2020 00:47:14 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2020-01-21T00:47:14Z</dc:date>
    <item>
      <title>ERROR: Expression using greater than (&gt;) has components that are of different data types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expression-using-greater-than-gt-has-components-that-are/m-p/618732#M181547</link>
      <description>&lt;P&gt;Hello! I am new to SAS and cant seem to get past this error after WHERE birthdate &amp;gt; 01/01/2001. When I run this I keep getting an error that says "ERROR: Expression using greater than (&amp;gt;) has components that are of different data types". They all have matching data types of:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;birthdate&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;MMDDYY10.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;birthdate&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;gender&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;$1.&lt;/TD&gt;&lt;TD&gt;$1.&lt;/TD&gt;&lt;TD&gt;gender&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;schoolID&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;BEST.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;schoolID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;schoolname&lt;/TD&gt;&lt;TD&gt;Char&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;$9.&lt;/TD&gt;&lt;TD&gt;$9.&lt;/TD&gt;&lt;TD&gt;schoolname&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;studentID&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;BEST.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;studentID&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Question 1*/&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE Data.master_WithSchoolInfo AS&lt;BR /&gt;SELECT A.studentID, A.Birthdate, A.Gender, B.SchoolID, B.SchoolName&lt;BR /&gt;FROM Data.master A LEFT JOIN Data.school B&lt;BR /&gt;ON A.SchoolID = B.SchoolID;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;PROC CONTENTS DATA = Data.master_WithSchoolInfo;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*Question 2*/&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE Data.master_After2001 AS&lt;BR /&gt;SELECT *&lt;BR /&gt;FROM Data.master_WithSchoolInfo&lt;BR /&gt;WHERE Birthdate &amp;gt; '01/01/2001';&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;PROC CONTENTS DATA = Data.master_WithSchoolAfter2001;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help me figure this out?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 00:29:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expression-using-greater-than-gt-has-components-that-are/m-p/618732#M181547</guid>
      <dc:creator>cneed</dc:creator>
      <dc:date>2020-01-21T00:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expression using greater than (&gt;) has components that are of different data types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expression-using-greater-than-gt-has-components-that-are/m-p/618738#M181548</link>
      <description>&lt;P&gt;Birthdate is a numeric variable but you are comparing it to a character string - '01/01/2001'. Changing your WHERE clause to use a date constant like so should fix your error:&lt;/P&gt;
&lt;PRE&gt;WHERE Birthdate &amp;gt; '01Dec2001'd&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 00:47:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expression-using-greater-than-gt-has-components-that-are/m-p/618738#M181548</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-01-21T00:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expression using greater than (&gt;) has components that are of different data types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expression-using-greater-than-gt-has-components-that-are/m-p/618740#M181550</link>
      <description>&lt;P&gt;Birthdate is likely a numerical variable containing a SAS date value (count of days since 01 Jan 1960). Normally a SAS format gets applied to such variables so when you look at it (print it) then the value becomes human readable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Execute below. This will tell you of what type the variables are and what formats they use (if any).&lt;/P&gt;
&lt;PRE&gt;proc contents data=Data.master; run;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;If above assumption is correct (birthdate being of type numeric containing a SAS date value) then you need to formulate the fixed date in your where clause also in a way which instructs SAS that this is a SAS date value. Below should work.&lt;/P&gt;
&lt;PRE&gt;WHERE Birthdate &amp;gt; '01JAN2001'd &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 00:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expression-using-greater-than-gt-has-components-that-are/m-p/618740#M181550</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-01-21T00:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Expression using greater than (&gt;) has components that are of different data types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Expression-using-greater-than-gt-has-components-that-are/m-p/618741#M181551</link>
      <description>&lt;P&gt;Thanks so much! It worked!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 01:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Expression-using-greater-than-gt-has-components-that-are/m-p/618741#M181551</guid>
      <dc:creator>cneed</dc:creator>
      <dc:date>2020-01-21T01:02:06Z</dc:date>
    </item>
  </channel>
</rss>

