<?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: Converting date from &amp;quot; DATETIME20.&amp;quot; format to SAS date format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125695#M260186</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is extremely difficult to provide data logic support without more details on your data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only thing I can think of that I would investigate is the interaction between select distinct a.nam and the group by statement. The fact that you group by b.nam and have the condition a.nam=b.nam should already alleviate the need for "distinct". Furthermore, if you have a distinct statement there, it means that your data might have multiple dtserv for a given nam. In that case, the distinct statement might have a bad interraction retaining only the first dtserv which may very well occur before or after the recruitment_dt?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway until you provide a small example of data (nam and establ don't have to be the same but using dates as they are in your data for the example would be very helpful), I can't be of much more help than say try to remove the distinct from distinct a.nam&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vincent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Aug 2013 11:41:53 GMT</pubDate>
    <dc:creator>Vince28_Statcan</dc:creator>
    <dc:date>2013-08-30T11:41:53Z</dc:date>
    <item>
      <title>Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125687#M260178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a data which has date in the &lt;STRONG&gt;DATETIME20.&lt;/STRONG&gt; format. I need date in sas format so that I can used a conditioning statement in my code for extracting some variables: for instance I want to use &lt;/P&gt;&lt;P&gt;WHERE &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; INTNX("MONTH",B.RECRUITMENT_DT,-3,"SAME")&amp;nbsp; &amp;lt;= datejul(input((a.DTSERV),5.))&amp;lt;= b.RECRUITMENT_DT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;group by b.nam&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now when I try to run the below code it doesn't work, I would really appreciate any help.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Tasneem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data map2.bill;&lt;/P&gt;&lt;P&gt;set&amp;nbsp; map2.bill ; &lt;/P&gt;&lt;P&gt;xdtserv=input(dtserv, 5.);&amp;nbsp; /*character to numeric*/&lt;/P&gt;&lt;P&gt;xxdtserv=datejul(xdtserv);&amp;nbsp; /*numeric to datesas*/&lt;/P&gt;&lt;P&gt;format xxdtserv date9.;&amp;nbsp; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=map2.bill;by nam&amp;nbsp; xxdtserv;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 18:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125687#M260178</guid>
      <dc:creator>TZaihra</dc:creator>
      <dc:date>2013-08-29T18:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125688#M260179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Lookup for DATEPART function (resp. timepart).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt='01JAN2011'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dttm=input('01JAN2011:00:00:00', datetime18.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dtpt = datepart(dttm);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if dt=dtpt then put "Hello World!";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 19:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125688#M260179</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-08-29T19:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125689#M260180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Just to confirm that I understand correctly, so what you are suggesting is that&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;WHERE &lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;INTNX("MONTH",B.RECRUITMENT_DT,-3,"SAME")&amp;nbsp; &amp;lt;= &lt;STRONG&gt;datepart(input((a.DTSERV),5.))&lt;/STRONG&gt;&amp;lt;= b.RECRUITMENT_DT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;and it should work, yeah?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 19:13:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125689#M260180</guid>
      <dc:creator>TZaihra</dc:creator>
      <dc:date>2013-08-29T19:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125690#M260181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, datepart is meant to be applied directly to a datetime value. Typically, datetimes are much larger than the 10000-99999 range in numeric value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I couldn't tell which one of your variables were datetime20., I only provided a mean to extract the date from a datetime value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't quite see where you have a datetime value in your dates. Could you provide an example both variables (dtserv before the input statement preferably) as well as their formats and informats?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 19:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125690#M260181</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-08-29T19:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125691#M260182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume a.dtserv is your datetime variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since it is already a datetime20. formatted variable, it means that it is stored as numeric already. Thus, using something like input(a.dtserv, 5.) only truncates the numeric representation of your datetime variable making it lose all of it's meaning.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that is the case, then you simply want to use datepart(a.dtserv). That will return you a roughly 5 digit numeric value representing a date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't provide better help without details on your variables or at least examples of their unformated and formated values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 19:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125691#M260182</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-08-29T19:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125692#M260183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DTSERV&amp;nbsp; variable looks like 05OCT2009:00:00:00 in SAS file and it's format is DATETIME20. &lt;/P&gt;&lt;P&gt;What I am doing is extracting let's say how many drugs were dispensed between the recruitment date and the service date and for that I use the following logic gate:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;WHERE &lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;INTNX("MONTH",B.RECRUITMENT_DT,-3,"SAME") &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt; &amp;lt;= datejul(input((a.DTSERV),5.))&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;lt;= b.RECRUITMENT_DT&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 19:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125692#M260183</guid>
      <dc:creator>TZaihra</dc:creator>
      <dc:date>2013-08-29T19:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125693#M260184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We replied roughly at the same time. Based on this new information, then my previous post (#4) is your desired approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;WHERE &lt;SPAN style="font-family: inherit; font-size: 10pt; font-style: inherit;"&gt;INTNX("MONTH",B.RECRUITMENT_DT,-3,"SAME") &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt; &amp;lt;= datepart(a.DTSERV)&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;lt;= b.RECRUITMENT_DT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: inherit; font-size: 10pt; font-style: inherit;"&gt;For format datetime20. to be possible, the value has to already be numeric, thus inputing with 5. format only truncates the values killing its representation.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 19:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125693#M260184</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-08-29T19:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125694#M260185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vince,&lt;/P&gt;&lt;P&gt;Thanks a lot for your guidance and help, I really appreciate it. However, if I do as you suggested above I end up getting following message wit a table which has no values..&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE TABLE HOSPITAL3_10 AS&lt;/P&gt;&lt;P&gt;SELECT distinct a.NAM, COUNT(distinct a.dtserv) AS HOSPITAL3&lt;/P&gt;&lt;P&gt;FROM MAP2.BILL as a,MAP.final_pool_10patients_1&amp;nbsp; as b&lt;/P&gt;&lt;P&gt;WHERE a.NAM=b.NAM and a.ESTABL IN ( "0xxx0","0xxx2")&lt;/P&gt;&lt;P&gt;and INTNX("MONTH",B.RECRUITMENT_DT,-3,"SAME")&amp;nbsp; &amp;lt;= datepart(a.DTSERV)&amp;lt;= b.RECRUITMENT_DT&lt;/P&gt;&lt;P&gt;group by b.nam&lt;/P&gt;&lt;P&gt;ORDER BY b.NAM;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The query requires re merging summary statistics back with the original data.&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.HOSPITAL3_10 created, with 0 rows and 2 columns.&lt;/P&gt;&lt;P&gt;I would really appreciate any suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Aug 2013 02:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125694#M260185</guid>
      <dc:creator>TZaihra</dc:creator>
      <dc:date>2013-08-30T02:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125695#M260186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is extremely difficult to provide data logic support without more details on your data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only thing I can think of that I would investigate is the interaction between select distinct a.nam and the group by statement. The fact that you group by b.nam and have the condition a.nam=b.nam should already alleviate the need for "distinct". Furthermore, if you have a distinct statement there, it means that your data might have multiple dtserv for a given nam. In that case, the distinct statement might have a bad interraction retaining only the first dtserv which may very well occur before or after the recruitment_dt?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway until you provide a small example of data (nam and establ don't have to be the same but using dates as they are in your data for the example would be very helpful), I can't be of much more help than say try to remove the distinct from distinct a.nam&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vincent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Aug 2013 11:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125695#M260186</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-08-30T11:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125696#M260187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the variable "looks like" &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;05OCT2009:00:00:00&lt;/SPAN&gt; and has a DATETIME20 format then the value should be the number of seconds since 1/1/1960. To convert it to a date use the DATEPART() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;dt = '05OCT2009:00:00:00'dt ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;d= datepart(dt);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;put dt= dt datetime20. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;put d= d date9. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;dt=1570320000&amp;nbsp;&amp;nbsp; 05OCT2009:00:00:00&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;d=18175 05OCT2009&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Aug 2013 12:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125696#M260187</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-08-30T12:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Converting date from " DATETIME20." format to SAS date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125697#M260188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Sep 2013 19:55:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-date-from-quot-DATETIME20-quot-format-to-SAS-date/m-p/125697#M260188</guid>
      <dc:creator>TZaihra</dc:creator>
      <dc:date>2013-09-01T19:55:56Z</dc:date>
    </item>
  </channel>
</rss>

