<?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: How to read date value with partial date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339568#M77482</link>
    <description>&lt;P&gt;Or without formats;&lt;/P&gt;
&lt;PRE&gt;data want (drop=mnth);
  length dstr $20;
  input dstr $;
  dstr=tranwrd(dstr,"UN","");
  if scan(dstr,2,"/") ne "" then mnth=put(month(input(cats("01",scan(dstr,2,"/"),"2010"),date9.)),z2.);
  formatted=catx("-",scan(dstr,3,"/"),mnth,scan(dstr,1,"/"));
datalines;
UN/Feb/2016
01/Mar/2014
UN/UN/2011
;
run;
&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Mar 2017 09:54:38 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-03-09T09:54:38Z</dc:date>
    <item>
      <title>How to read a date value with partial dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339543#M77466</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running following program. i am not getting the out I need. please suggest. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;input cmendtc_raw $11.;&lt;BR /&gt;datalines;&lt;BR /&gt;UN/Feb/2015&lt;BR /&gt;;&lt;BR /&gt;data two;&lt;BR /&gt;set one;&lt;BR /&gt;cmendtc=put(input(cmendtc_raw, ?? date11.),yymmdd10.);&lt;/P&gt;&lt;P&gt;if missing(cmendtc) and not missing(cmendtc_raw) then&lt;BR /&gt;do;&lt;BR /&gt;length _day1 _month1 _year1 8;&lt;BR /&gt;_day1 =input(scan(cmendtc_raw,1,'/','m'), ?? best32.);&lt;BR /&gt;_month1=month(input(scan(cmendtc_raw,2,'/','m')||'2000', ?? monyy.));&lt;BR /&gt;_year1 =input(scan(cmendtc_raw,3,'/','m'),?? best32.);&lt;BR /&gt;end;&lt;BR /&gt;if _day1&amp;lt;1 or _day1&amp;gt;31 then call missing(_day1);&lt;BR /&gt;if _month1&amp;lt;1 or _month1&amp;gt;12 then call missing(_month1);&lt;/P&gt;&lt;P&gt;/* valid day and year? */&lt;BR /&gt;if mdy(01,_day1,_year1) then cmendtc=put(_year1,z4.)||'--'||put(_day1,z2.);&lt;/P&gt;&lt;P&gt;/* valid month and year? */&lt;BR /&gt;else if mdy(_month1,01,_year1) then cmendtc=put(_year1,z4.)||'-'||put(_month1,z2.);&lt;/P&gt;&lt;P&gt;/* valid year? */&lt;BR /&gt;else if mdy(02,01,_year1) then cmendtc=put(_year1,z4.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output need:&lt;/P&gt;&lt;P&gt;2015-02&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am seeing a blank value &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;"&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.' &amp;nbsp;&amp;nbsp;&lt;FONT color="#000000"&gt;. The missing function is not recognizing. Please help. Thank you&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 05:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339543#M77466</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-03-09T05:42:47Z</dc:date>
    </item>
    <item>
      <title>How to read date value with partial date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339544#M77473</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running following program. i am not getting the out I need. please suggest. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;input cmendtc_raw $11.;&lt;BR /&gt;datalines;&lt;BR /&gt;UN/Feb/2015&lt;BR /&gt;;&lt;BR /&gt;data two;&lt;BR /&gt;set one;&lt;BR /&gt;cmendtc=put(input(cmendtc_raw, ?? date11.),yymmdd10.);&lt;/P&gt;&lt;P&gt;if missing(cmendtc) and not missing(cmendtc_raw) then&lt;BR /&gt;do;&lt;BR /&gt;length _day1 _month1 _year1 8;&lt;BR /&gt;_day1 =input(scan(cmendtc_raw,1,'/','m'), ?? best32.);&lt;BR /&gt;_month1=month(input(scan(cmendtc_raw,2,'/','m')||'2000', ?? monyy.));&lt;BR /&gt;_year1 =input(scan(cmendtc_raw,3,'/','m'),?? best32.);&lt;BR /&gt;end;&lt;BR /&gt;if _day1&amp;lt;1 or _day1&amp;gt;31 then call missing(_day1);&lt;BR /&gt;if _month1&amp;lt;1 or _month1&amp;gt;12 then call missing(_month1);&lt;/P&gt;&lt;P&gt;/* valid day and year? */&lt;BR /&gt;if mdy(01,_day1,_year1) then cmendtc=put(_year1,z4.)||'--'||put(_day1,z2.);&lt;/P&gt;&lt;P&gt;/* valid month and year? */&lt;BR /&gt;else if mdy(_month1,01,_year1) then cmendtc=put(_year1,z4.)||'-'||put(_month1,z2.);&lt;/P&gt;&lt;P&gt;/* valid year? */&lt;BR /&gt;else if mdy(02,01,_year1) then cmendtc=put(_year1,z4.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output need:&lt;/P&gt;&lt;P&gt;2015-02&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am seeing a blank value &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;"&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.' &amp;nbsp;&amp;nbsp;&lt;FONT color="#000000"&gt;. The missing function is not recognizing. Please help. Thank you&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 05:44:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339544#M77473</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-03-09T05:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to read date value with partial date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339556#M77474</link>
      <description>&lt;P&gt;Why so complicated?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input cmendtc_raw $11.;
datalines;
UN/Feb/2015
;
run;

proc format;
value $monthrev
  'Jan' = '-01'
  'Feb' = '-02'
  'Mar' = '-03'
/* add other months here */
  other = '   '
;
run;

data want;
set have;
length cmendtc $10;
cmendtc = scan(cmendtc_raw,3,'/') !! put(scan(cmendtc_raw,2,'/'),$monthrev3.);
if substr(cmendtc_raw,1,2) ne 'UN' then cmendtc = trim(cmendtc) !! substr(cmendtc_raw,1,2);
run;

proc print data=want noobs;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;cmendtc_raw    cmendtc

UN/Feb/2015    2015-02
&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 07:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339556#M77474</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-09T07:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to read a date value with partial dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339557#M77475</link>
      <description>&lt;P&gt;And reread &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/How-to-convert-date-to-character-dates-when-source-date-contain/m-p/303652" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-to-convert-date-to-character-dates-when-source-date-contain/m-p/303652&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;There were a lot of good hints and suggestions there.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 07:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339557#M77475</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-09T07:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to read date value with partial date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339568#M77482</link>
      <description>&lt;P&gt;Or without formats;&lt;/P&gt;
&lt;PRE&gt;data want (drop=mnth);
  length dstr $20;
  input dstr $;
  dstr=tranwrd(dstr,"UN","");
  if scan(dstr,2,"/") ne "" then mnth=put(month(input(cats("01",scan(dstr,2,"/"),"2010"),date9.)),z2.);
  formatted=catx("-",scan(dstr,3,"/"),mnth,scan(dstr,1,"/"));
datalines;
UN/Feb/2016
01/Mar/2014
UN/UN/2011
;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 09:54:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-a-date-value-with-partial-dates/m-p/339568#M77482</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-09T09:54:38Z</dc:date>
    </item>
  </channel>
</rss>

