<?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: checking missing date in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248408#M56409</link>
    <description>here is my code --&amp;gt;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;  set have;&lt;BR /&gt;  &lt;BR /&gt;  day=substr(birthdate,1,1);&lt;BR /&gt;  month=substr(birthdate,2,1);&lt;BR /&gt;  year=substr(birthdate,7,1);&lt;BR /&gt; &lt;BR /&gt;  if day eq "-" and month eq "-" then year=substr(birthdate,3,4); &lt;BR /&gt;  else if day eq "-" and month ne "-" then year=substr(birthdate,6,4);&lt;BR /&gt;  else if year eq "-"  then year="0000";&lt;BR /&gt;  else if month eq "-" then year=substr(birthdate,5,4);&lt;BR /&gt; &lt;BR /&gt;  &lt;BR /&gt;  if day eq "-" then day="01";&lt;BR /&gt;  else if day ne "-" then do;&lt;BR /&gt;  	 day=substr(birthdate,1,2); /*Day*/&lt;BR /&gt;  	 month=substr(birthdate,3,1);&lt;BR /&gt;  end;&lt;BR /&gt;  &lt;BR /&gt;  if month eq "-" then month="Jan";&lt;BR /&gt;  else if month ne "-" then month=substr(birthdate,2,3);&lt;BR /&gt;  &lt;BR /&gt;   converted_date=day||"-"||month||"-"||year;&lt;BR /&gt;run;&lt;BR /&gt; but there is a issue my output has some missing values--&amp;gt; here is my output data&lt;BR /&gt;&lt;BR /&gt;	&lt;BR /&gt;birthdate&lt;BR /&gt;day&lt;BR /&gt;month&lt;BR /&gt;year&lt;BR /&gt;converted_date&lt;BR /&gt;1	-Jan-1975 01	Jan	1975        01 -Jan-1975&lt;BR /&gt;2	--1977	 01	Jan	1977	01 -Jan -1977&lt;BR /&gt;3	02--1978	 02	Jan	7	        02 -Jan -7&lt;BR /&gt;4	03-Jan-	 03	Jan	0000	03 -Jan -0000&lt;BR /&gt;&lt;BR /&gt;in the 3 observation the year isn't getting displayed so whats the issue i can't solve &amp;amp; the code has zero errors</description>
    <pubDate>Fri, 05 Feb 2016 21:20:36 GMT</pubDate>
    <dc:creator>RTelang</dc:creator>
    <dc:date>2016-02-05T21:20:36Z</dc:date>
    <item>
      <title>checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/247937#M56346</link>
      <description>&lt;P&gt;here am writing d code to check missing day month year from the input below &amp;nbsp;&amp;amp; display the correct format according to the given values below. my input dates are&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-MMM-YYYY&amp;nbsp;&lt;BR /&gt;--YYYY&amp;nbsp;&lt;BR /&gt;DD--YYYY&amp;nbsp;&lt;BR /&gt;DD-MMM-&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the values to display according to the coressponding input value&amp;nbsp;in the output are--&amp;gt;&lt;/P&gt;
&lt;P&gt;-MMM-YYYY = 01-MMM-YYYY&lt;BR /&gt;--YYYY = 01-JAN-YYYY&lt;BR /&gt;DD--YYYY = DD-JAN-YYYY&lt;BR /&gt;DD-MMM- = DD-MMM-0000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is my code to take string &amp;amp; display it but it gives a missing output what can i do to&amp;nbsp;&lt;SPAN&gt;read the input&amp;nbsp;then see wats missing then display the respective outputs&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data date;&lt;BR /&gt;str ='-jan-1988';&lt;BR /&gt;date1= input(str,anydtdte11.);&lt;BR /&gt;format date1 mmddyyd10.&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 10:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/247937#M56346</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-04T10:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/247943#M56347</link>
      <description>&lt;P&gt;What is your rules for what gets replaced in the missing parts. &amp;nbsp;SAS dates can only have all parts presetn, so you need rules like:&lt;/P&gt;
&lt;P&gt;If day is missing then assume 01&lt;/P&gt;
&lt;P&gt;If month is missing then assume Jan&lt;/P&gt;
&lt;P&gt;If Year is missing then assume 2015&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you code those rules in:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  day=substr(date,1,2);
  month=substr(date,3,3);
  year=substr(date,6,4);
  if day="--" then day="01";
  if month="--" then month="JAN";
  if year="--" then year="2015";
  converted_data=input(cats(day,month,year),date9.);
  format converted_date date9.;
run;&lt;/PRE&gt;
&lt;P&gt;The above is to show the working.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 11:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/247943#M56347</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-04T11:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/247944#M56348</link>
      <description>hello RW9 here my 4 inputs are having missing day month  year &amp;amp; day month.. so u say i create a data set with my inputs &amp;amp; then use ur logic &amp;amp; can i use it as macro.. &lt;BR /&gt;</description>
      <pubDate>Thu, 04 Feb 2016 11:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/247944#M56348</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-04T11:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/247946#M56349</link>
      <description>&lt;P&gt;Yes, what you want to do is to check each part of the string provided in date. &amp;nbsp;You do this by using:&lt;/P&gt;
&lt;P&gt;if &amp;lt;condition&amp;gt; then &amp;lt;result&amp;gt;;&lt;/P&gt;
&lt;P&gt;Setup (or similar select when). &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Converting the string to date will just create missings where the complete date is not present, as SAS does not have a "default" for missing data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for "&lt;SPAN&gt;can i use it as macro..", not directly, this code is written in Base SAS, for use with datasets - i.e. the language used to process data. &amp;nbsp;Macro is a text generation facility, it is not advisable to start doing data related processing in a text generation language, otherwise you will end up with messy obfuscated code. &amp;nbsp;The most important thing to learn about any technology is when to use it, and more impoartantly when not to use it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2016 11:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/247946#M56349</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-04T11:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248163#M56377</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; am using a input dataset have still there error exist</description>
      <pubDate>Fri, 05 Feb 2016 05:31:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248163#M56377</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-05T05:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248179#M56385</link>
      <description>@ rw9 here's my log with the code &amp;amp; errors...&lt;BR /&gt; &lt;BR /&gt;57         data have;&lt;BR /&gt; 58         input birthdate $;&lt;BR /&gt; 59         cards;&lt;BR /&gt; &lt;BR /&gt; NOTE: The data set WORK.HAVE has 4 observations and 1 variables.&lt;BR /&gt; NOTE: DATA statement used (Total process time):&lt;BR /&gt;       real time           0.03 seconds&lt;BR /&gt;       cpu time            0.02 seconds&lt;BR /&gt;       &lt;BR /&gt; 64         run;&lt;BR /&gt; &lt;BR /&gt; 65         &lt;BR /&gt; 66         data want;&lt;BR /&gt; 67           set have;&lt;BR /&gt; 68           day=substr(birthdate,1,2);&lt;BR /&gt; 69           month=substr(birthdate,5,7);&lt;BR /&gt; 70           year=substr(birthdate,8,6);&lt;BR /&gt; 71           if day="-" then day="01";&lt;BR /&gt; 72           if month="--" then month="JAN";&lt;BR /&gt; 73           if year="-" then year="0000";&lt;BR /&gt; 74           converted_date=input(cats(day,month,year),date9.);&lt;BR /&gt; 75           format converted_date date9.;&lt;BR /&gt; 76         run;&lt;BR /&gt; &lt;BR /&gt; NOTE: Invalid third argument to function SUBSTR at line 69 column 9.&lt;BR /&gt; NOTE: Invalid third argument to function SUBSTR at line 70 column 8.&lt;BR /&gt; NOTE: Invalid argument to function INPUT at line 74 column 18.&lt;BR /&gt; birthdate=-Jan-197 day=-J month=-197 year=7 converted_date=. _ERROR_=1 _N_=1&lt;BR /&gt; NOTE: Invalid third argument to function SUBSTR at line 69 column 9.&lt;BR /&gt; NOTE: Invalid third argument to function SUBSTR at line 70 column 8.&lt;BR /&gt; NOTE: Invalid argument to function INPUT at line 74 column 18.&lt;BR /&gt; birthdate=--1977 day=-- month=77 year=  converted_date=. _ERROR_=1 _N_=2&lt;BR /&gt; NOTE: Invalid third argument to function SUBSTR at line 69 column 9.&lt;BR /&gt; NOTE: Invalid third argument to function SUBSTR at line 70 column 8.&lt;BR /&gt; NOTE: Invalid argument to function INPUT at line 74 column 18.&lt;BR /&gt; birthdate=02--1978 day=02 month=1978 year=8 converted_date=. _ERROR_=1 _N_=3&lt;BR /&gt; NOTE: Invalid third argument to function SUBSTR at line 69 column 9.&lt;BR /&gt; NOTE: Invalid third argument to function SUBSTR at line 70 column 8.&lt;BR /&gt; NOTE: Invalid argument to function INPUT at line 74 column 18.&lt;BR /&gt; birthdate=03-Jan- day=03 month=an- year=  converted_date=. _ERROR_=1 _N_=4&lt;BR /&gt; NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to &lt;BR /&gt;       missing values.&lt;BR /&gt;       Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;       4 at 74:18   &lt;BR /&gt; NOTE: There were 4 observations read from the data set WORK.HAVE.&lt;BR /&gt; NOTE: The data set WORK.WANT has 4 observations and 5 variables.</description>
      <pubDate>Fri, 05 Feb 2016 07:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248179#M56385</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-05T07:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248181#M56386</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;here my input datastep &lt;BR /&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input birthdate $;&lt;BR /&gt;cards;&lt;BR /&gt;-Jan-1975&lt;BR /&gt;--1977&lt;BR /&gt;02--1978&lt;BR /&gt;03-Jan- &lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&amp;amp; its log&lt;BR /&gt; &lt;BR /&gt;birthdate&lt;BR /&gt;1 -Jan-197&lt;BR /&gt;2 --1977&lt;BR /&gt;3 02--1978&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2016 08:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248181#M56386</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-05T08:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248198#M56387</link>
      <description>&lt;P&gt;So what is your logic here, your data doesn't seem to match. &amp;nbsp;Take two of the examples:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;--1977&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;02--1978&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the first, month is one single "-", in the second month is two "-". &amp;nbsp;It shiould either be one - for missing, or 3 - missing -.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What are the rules to identify the three parts from the date?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have done what I can with the data, its really not good to accept un-logical data like this though:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data have;
  length day $2 month $3 year $4 birthdate $11;
  input birthdate $;
cards;
-Jan-1975
--1977
02--1978
03-Jan- 
run;

data want;
  set have;
  length day $2 month $3 year $4;
  month=compress(birthdate," ","ka");
  birthdate=tranwrd(compress(tranwrd(birthdate,month,"")," "),"--","-");
  day=substr(birthdate,1,index(birthdate,"-"));
  birthdate=substr(birthdate,index(birthdate,"-")+1);
  year=birthdate;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Feb 2016 10:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248198#M56387</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-05T10:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248200#M56388</link>
      <description>for example see this 	&lt;BR /&gt;01-Jan-1975&lt;BR /&gt;05-jan-1977&lt;BR /&gt;02-jan-1978&lt;BR /&gt;03-Jan-0000&lt;BR /&gt;this is the actual format the dash is between    day-month-year u get it so in the 2 &amp;amp; 3 card line its '--' '--'</description>
      <pubDate>Fri, 05 Feb 2016 10:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248200#M56388</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-05T10:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248204#M56390</link>
      <description>&lt;P&gt;Sorry, I don't see any "--" in that exampe data. &amp;nbsp;From that example data I would just use scan, but this doesn't show missings. &amp;nbsp;Post smoe test data which shows your data, exactly, with each of the combinations.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2016 10:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248204#M56390</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-05T10:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248205#M56391</link>
      <description>-Jan-1975&lt;BR /&gt;--1977&lt;BR /&gt;02--1978&lt;BR /&gt;03-Jan-  this are the dates i have.&lt;BR /&gt;so for example --1977 so its converted date format is 05-jan-1977</description>
      <pubDate>Fri, 05 Feb 2016 10:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248205#M56391</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-05T10:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248206#M56392</link>
      <description>&lt;P&gt;Sorry, we are back to my previous point then:&lt;/P&gt;
&lt;P&gt;So what is your logic here, your data doesn't seem to match. &amp;nbsp;Take two of the examples:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;--1977&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;02--1978&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the first, month is one single "-", in the second month is two "-". &amp;nbsp;It shiould either be one - for missing, or 3 - missing -.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What are the rules to identify the three parts from the date?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's no logic provided which states in one record month could be --, in another record it could be -.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To add to that, how do you know that --1977 should be 05-jan-1977? &amp;nbsp;What are your rules on the data, how are you going to clean it. &amp;nbsp;The code I provided should give you a good start in splitting the string up, you now need to work out what your logic and rules will be on missing data.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2016 10:55:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248206#M56392</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-05T10:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248209#M56393</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; can i use ur first code logic against my new inputs -Jan-1975&lt;BR /&gt;--1977&lt;BR /&gt;02--1978&lt;BR /&gt;03-Jan- ?? can we change the if the conditions or the substr condition..?</description>
      <pubDate>Fri, 05 Feb 2016 11:05:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248209#M56393</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-05T11:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248210#M56394</link>
      <description>my original post&lt;BR /&gt; -MMM-YYYY = 01-MMM-YYYY&lt;BR /&gt;--YYYY = 01-JAN-YYYY&lt;BR /&gt;DD--YYYY = DD-JAN-YYYY&lt;BR /&gt;DD-MMM- = DD-MMM-0000&lt;BR /&gt;&lt;BR /&gt;inputs to the left &amp;amp; the required output needed to the right after '=' so....my input dataset i created based on the values in the left &amp;amp; want to display the values to the right as our first logic example u provided.. can we do it to the input code</description>
      <pubDate>Fri, 05 Feb 2016 11:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248210#M56394</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-05T11:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248215#M56395</link>
      <description>&lt;P&gt;Yes, so as mentioned before its two part. &amp;nbsp;First separate out the individual parts. &amp;nbsp;You are ignoring my point with regards to logical assignment of -- versus -, so I will just make assumptions. &amp;nbsp;The second part is to assign the required replacements for missing values, and then input the result. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the datastep below, the first part of the datastep separates out the components, the second adds in your rules.&lt;/P&gt;
&lt;PRE&gt;data have;
  length day $2 month $3 year $4 birthdate old $11;
  input birthdate $;
  old=birthdate;
cards;
-Jan-1975
--1977
02--1978
03-Jan- 
run;

data want;
  set have;
  length day $2 month $3 year $4;
  month=compress(birthdate," ","ka");
  birthdate=tranwrd(compress(tranwrd(birthdate,month,"")," "),"--","-");
  day=tranwrd(substr(birthdate,1,index(birthdate,"-")),"-","");
  birthdate=substr(birthdate,index(birthdate,"-")+1);
  year=birthdate;
  /* Your rules here */
  if day="" and month ne "" and year ne "" then new_date=input(cats("01",month,year),date9.);
  else if day="" and month="" and year ne "" then new_date=input(cats("01JAN",year),date9.);
  else if day ne "" and month="" and year ne "" then new_date=input(cats(day,"JAN",year),date9.);
  else if day ne "" and month ne "" and year="" then new_date=input(cats(day,month,"2000"),date9.); 
  format new_date date9.;
run;
&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Feb 2016 12:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248215#M56395</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-05T12:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248408#M56409</link>
      <description>here is my code --&amp;gt;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;  set have;&lt;BR /&gt;  &lt;BR /&gt;  day=substr(birthdate,1,1);&lt;BR /&gt;  month=substr(birthdate,2,1);&lt;BR /&gt;  year=substr(birthdate,7,1);&lt;BR /&gt; &lt;BR /&gt;  if day eq "-" and month eq "-" then year=substr(birthdate,3,4); &lt;BR /&gt;  else if day eq "-" and month ne "-" then year=substr(birthdate,6,4);&lt;BR /&gt;  else if year eq "-"  then year="0000";&lt;BR /&gt;  else if month eq "-" then year=substr(birthdate,5,4);&lt;BR /&gt; &lt;BR /&gt;  &lt;BR /&gt;  if day eq "-" then day="01";&lt;BR /&gt;  else if day ne "-" then do;&lt;BR /&gt;  	 day=substr(birthdate,1,2); /*Day*/&lt;BR /&gt;  	 month=substr(birthdate,3,1);&lt;BR /&gt;  end;&lt;BR /&gt;  &lt;BR /&gt;  if month eq "-" then month="Jan";&lt;BR /&gt;  else if month ne "-" then month=substr(birthdate,2,3);&lt;BR /&gt;  &lt;BR /&gt;   converted_date=day||"-"||month||"-"||year;&lt;BR /&gt;run;&lt;BR /&gt; but there is a issue my output has some missing values--&amp;gt; here is my output data&lt;BR /&gt;&lt;BR /&gt;	&lt;BR /&gt;birthdate&lt;BR /&gt;day&lt;BR /&gt;month&lt;BR /&gt;year&lt;BR /&gt;converted_date&lt;BR /&gt;1	-Jan-1975 01	Jan	1975        01 -Jan-1975&lt;BR /&gt;2	--1977	 01	Jan	1977	01 -Jan -1977&lt;BR /&gt;3	02--1978	 02	Jan	7	        02 -Jan -7&lt;BR /&gt;4	03-Jan-	 03	Jan	0000	03 -Jan -0000&lt;BR /&gt;&lt;BR /&gt;in the 3 observation the year isn't getting displayed so whats the issue i can't solve &amp;amp; the code has zero errors</description>
      <pubDate>Fri, 05 Feb 2016 21:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248408#M56409</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-05T21:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248465#M56430</link>
      <description>&lt;P&gt;Part of your issue is you haven't broken the code up to identify all of your possible cases. 1) all values missing, 2) all but day missing, 3) all but month missing, 4) all but year missing, 5) ony missing day, 6) only missing month, 7) missing only year and finally &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; missing no values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance with your third record and the value of 02--1978&lt;/P&gt;
&lt;P&gt;None of this code gets executed:&lt;/P&gt;
&lt;PRE&gt;if day eq "-" and month eq "-" then year=substr(birthdate,3,4);
else if day eq "-" and month ne "-" then year=substr(birthdate,6,4);
else if year eq "-" then year="0000";
else if month eq "-" then year=substr(birthdate,5,4);&lt;/PRE&gt;
&lt;P&gt;because "day" = 0, "month"=2 and "year"=7&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And for the case where day is ne - and month ne - you never re-read the year so you get that single digit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm answering this away from my SAS install and have an idea I can't test at this time that may be much simpler over all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2016 08:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248465#M56430</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-06T08:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: checking missing date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248466#M56431</link>
      <description>@ballard &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; thanks solved the issue..</description>
      <pubDate>Sat, 06 Feb 2016 09:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/checking-missing-date/m-p/248466#M56431</guid>
      <dc:creator>RTelang</dc:creator>
      <dc:date>2016-02-06T09:26:43Z</dc:date>
    </item>
  </channel>
</rss>

