<?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: Variable is character and numeric both in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-is-character-and-numeric-both/m-p/739676#M230899</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/380276"&gt;@anandmgjsa&lt;/a&gt;&amp;nbsp; I have modified your code as shown below.&lt;BR /&gt;This should solve your problem&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data login_old;
format date yymmdd10.;
input date yymmdd10.;
datalines;
2020-10-11
2020-10-19
2020-10-01
2020-11-21
2020-12-30
2020-11-13
2020-06-22
;
run;
data login_oct_dec;
format date yymmdd10.;
set login_old ;
if (date &amp;gt; input("2020-10-01",yymmdd10.) and date &amp;lt; input("2020-12-31",yymmdd10.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output will be like this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="output.PNG" style="width: 247px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59120iCB643EF41F9C1CAA/image-size/large?v=v2&amp;amp;px=999" role="button" title="output.PNG" alt="output.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 06 May 2021 23:23:48 GMT</pubDate>
    <dc:creator>Sajid01</dc:creator>
    <dc:date>2021-05-06T23:23:48Z</dc:date>
    <item>
      <title>Variable is character and numeric both</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-is-character-and-numeric-both/m-p/739636#M230882</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am setting two data sets.Please find my code below :&lt;/P&gt;&lt;P&gt;data login_oct_dec;&lt;/P&gt;&lt;P&gt;set login_old Oct_Dec_Data;&lt;/P&gt;&lt;P&gt;if (date &amp;gt; '2020-10-01' and date &amp;lt; '2020-12-31');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;In this error is : variable date is character and numeric both.&lt;/P&gt;&lt;P&gt;Using proc contents , i found that in login_old , date is char while in Oct_Dec_Data, date is num.&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 20:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-is-character-and-numeric-both/m-p/739636#M230882</guid>
      <dc:creator>anandmgjsa</dc:creator>
      <dc:date>2021-05-06T20:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Variable is character and numeric both</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-is-character-and-numeric-both/m-p/739639#M230885</link>
      <description>&lt;P&gt;Probably best is to convert the character version to a date value. That, from your code would look like:&lt;/P&gt;
&lt;PRE&gt;data login_oct_dec;
   set login_old (rename=(date=chardate)) 
        Oct_Dec_Data;
  if not missing(chardate) then date=input(chardate,yymmdd10.);

run;&lt;/PRE&gt;
&lt;P&gt;Character comparisons involving &amp;gt; or &amp;lt; are mostly a bad idea.&lt;/P&gt;
&lt;P&gt;To specify literal values for dates in comparisons the appearance is a quoted DATE9. followed by d. Date9 means ddMONyyyy or 01JAN2021, and the literal value to use in code would be '01Jan2021'd.&lt;/P&gt;
&lt;P&gt;Question though, did you intend to exclude 01OCT2020 and 31DEC2020? That is what the &amp;lt; and &amp;gt; would do.&lt;/P&gt;
&lt;P&gt;If you want all the records with dates including&amp;nbsp;01OCT2020 and 31DEC2020 you would use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if '01OCT2020'd le date le '31DEC2020'd;&lt;/P&gt;
&lt;P&gt;if you actually do not want the end points:&lt;/P&gt;
&lt;P&gt;if '01OCT2020'd lt date lt '31DEC2020'd; (or use &amp;lt; instead of lt )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 20:37:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-is-character-and-numeric-both/m-p/739639#M230885</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-06T20:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Variable is character and numeric both</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-is-character-and-numeric-both/m-p/739676#M230899</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/380276"&gt;@anandmgjsa&lt;/a&gt;&amp;nbsp; I have modified your code as shown below.&lt;BR /&gt;This should solve your problem&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data login_old;
format date yymmdd10.;
input date yymmdd10.;
datalines;
2020-10-11
2020-10-19
2020-10-01
2020-11-21
2020-12-30
2020-11-13
2020-06-22
;
run;
data login_oct_dec;
format date yymmdd10.;
set login_old ;
if (date &amp;gt; input("2020-10-01",yymmdd10.) and date &amp;lt; input("2020-12-31",yymmdd10.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output will be like this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="output.PNG" style="width: 247px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59120iCB643EF41F9C1CAA/image-size/large?v=v2&amp;amp;px=999" role="button" title="output.PNG" alt="output.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 23:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-is-character-and-numeric-both/m-p/739676#M230899</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-05-06T23:23:48Z</dc:date>
    </item>
  </channel>
</rss>

