<?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: Identifing date of encounters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Re-Identifing-date-of-encounters/m-p/868921#M343268</link>
    <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I'm working with a dateset that has a start date and an end date for certain events. The format for both date fields is YYMMDDN8. I'm using the following lines of code to generate a count of days from the start date to the end date:&lt;/P&gt;&lt;PRE&gt;proc sql;
create table dataset2
as select distinct *, 
intck('day', datestartrole, dateendrole) as roletime "Time at Role"
from dataset1;
quit;&lt;/PRE&gt;&lt;P&gt;This works perfectly for most observations; however some observations of dateendrole are coded C for "current" even though dateendrole is in the YYMMDDN8. format. My code returns a missing value for those observations. I tried to modify by using the following code:&lt;/P&gt;&lt;PRE&gt;proc sql;
create table dataset2 
as select distinct *,
case when (dateendrole = 'C') then intck('day', datestartrole, today()) else intck('day', datestartrole, dateendrole) end as roletime "Time at Role"
from dataset1;
quit;&lt;/PRE&gt;&lt;P&gt;However, this returns an error stating "Expression using equals (=) has components that are of different data types." So, even though the date field is coded as a C, the case when statement is not recognizing C as a valid value because dateendrole is a date field. Do you guys have any ideas on how to get around this?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 10 Apr 2023 19:37:37 GMT</pubDate>
    <dc:creator>wanijsena</dc:creator>
    <dc:date>2023-04-10T19:37:37Z</dc:date>
    <item>
      <title>Re: Identifing date of encounters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Identifing-date-of-encounters/m-p/868921#M343268</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I'm working with a dateset that has a start date and an end date for certain events. The format for both date fields is YYMMDDN8. I'm using the following lines of code to generate a count of days from the start date to the end date:&lt;/P&gt;&lt;PRE&gt;proc sql;
create table dataset2
as select distinct *, 
intck('day', datestartrole, dateendrole) as roletime "Time at Role"
from dataset1;
quit;&lt;/PRE&gt;&lt;P&gt;This works perfectly for most observations; however some observations of dateendrole are coded C for "current" even though dateendrole is in the YYMMDDN8. format. My code returns a missing value for those observations. I tried to modify by using the following code:&lt;/P&gt;&lt;PRE&gt;proc sql;
create table dataset2 
as select distinct *,
case when (dateendrole = 'C') then intck('day', datestartrole, today()) else intck('day', datestartrole, dateendrole) end as roletime "Time at Role"
from dataset1;
quit;&lt;/PRE&gt;&lt;P&gt;However, this returns an error stating "Expression using equals (=) has components that are of different data types." So, even though the date field is coded as a C, the case when statement is not recognizing C as a valid value because dateendrole is a date field. Do you guys have any ideas on how to get around this?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 10 Apr 2023 19:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Identifing-date-of-encounters/m-p/868921#M343268</guid>
      <dc:creator>wanijsena</dc:creator>
      <dc:date>2023-04-10T19:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Identifing date of encounters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Identifing-date-of-encounters/m-p/868929#M343269</link>
      <description>&lt;P&gt;I've moved your question to it's own post as it doesn't relate to post where it was located. &lt;BR /&gt;&lt;BR /&gt;To answer your question, please run a proc contents on your 'dataset1' and include the type and format on your variable dateendrole. It is possibly numeric with a character format so it's not really a C.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;EDIT: Actually, even in your question you treat it as a date and character variable at the same time. I suspect you're referring to the incorrect variable somewhere.&lt;/P&gt;
&lt;P&gt;Character:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when (&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;dateendrole&lt;/FONT&gt;&lt;/STRONG&gt; = 'C') &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Numeric/Date&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; intck('day', datestartrole, &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;dateendrole&lt;/STRONG&gt;&lt;/FONT&gt;)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/441673"&gt;@wanijsena&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;
&lt;P&gt;I'm working with a dateset that has a start date and an end date for certain events. The format for both date fields is YYMMDDN8. I'm using the following lines of code to generate a count of days from the start date to the end date:&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table dataset2
as select distinct *, 
intck('day', datestartrole, dateendrole) as roletime "Time at Role"
from dataset1;
quit;&lt;/PRE&gt;
&lt;P&gt;This works perfectly for most observations; however some observations of dateendrole are coded C for "current" even though dateendrole is in the YYMMDDN8. format. My code returns a missing value for those observations. I tried to modify by using the following code:&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table dataset2 
as select distinct *,
case when (dateendrole = 'C') then intck('day', datestartrole, today()) else intck('day', datestartrole, dateendrole) end as roletime "Time at Role"
from dataset1;
quit;&lt;/PRE&gt;
&lt;P&gt;However, this returns an error stating "Expression using equals (=) has components that are of different data types." So, even though the date field is coded as a C, the case when statement is not recognizing C as a valid value because dateendrole is a date field. Do you guys have any ideas on how to get around this?&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 19:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Identifing-date-of-encounters/m-p/868929#M343269</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-04-10T19:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Identifing date of encounters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Identifing-date-of-encounters/m-p/868939#M343272</link>
      <description>&lt;P&gt;Are you sure the value you see is&lt;/P&gt;
&lt;PRE&gt;C&lt;/PRE&gt;
&lt;P&gt;and not&lt;/P&gt;
&lt;PRE&gt;.C&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;lt;dot&amp;gt;C is a "special missing value". If you want to check for it, use the MISSING function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, it is not necessary to use INTCK with an interval of "day"; SAS dates are counts of days, so a simple subtraction will do.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 20:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Identifing-date-of-encounters/m-p/868939#M343272</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-10T20:25:38Z</dc:date>
    </item>
  </channel>
</rss>

