<?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: Splitting data based on date format type in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325440#M72379</link>
    <description>Thank you. I am trying this now. Would you mind explaining what this code is doing so that I will know for the future? Will I be getting three separate datasets?</description>
    <pubDate>Tue, 17 Jan 2017 19:47:30 GMT</pubDate>
    <dc:creator>PaulaC</dc:creator>
    <dc:date>2017-01-17T19:47:30Z</dc:date>
    <item>
      <title>Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325399#M72369</link>
      <description>&lt;P&gt;I have a dataset that has a diagnosis date variable. &amp;nbsp;This variable is a character variable. &amp;nbsp;I would like to use this variable to cacluate the duration since diagnosis (randomization date-diagnosis date). &amp;nbsp;Unfortunately the variable is stored in three different way for the subjects. &amp;nbsp;I have about 40 subjects with only a year, 50 subjects with just a month and year and the remainder have a month, day and year. &amp;nbsp;I want to split the dataset by the way the diagnosis date is reported and then impute the date where the missing information is present. &amp;nbsp;After the imputation, I am planning on merging all the data back together.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is currently as yyyy(40 subjects), mmmyyyy (50 subjects) and ddmmmyyyy(remainder)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am expecting to have three datasets after the split.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used the following code in SAS 9.4 and it did not work (error message also included):&lt;/P&gt;&lt;P&gt;113 data diagfix1;&lt;BR /&gt;114 set disease;&lt;BR /&gt;115 if diagdate=diagdate year4.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;------&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 388&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 201&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 76&lt;BR /&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/P&gt;&lt;P&gt;ERROR 201-322: The option is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;116 run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help on how to split this data based on the date format would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 18:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325399#M72369</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-17T18:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325407#M72371</link>
      <description>&lt;P&gt;It would help to see some example data. It appears that all 3 types are in the same variable. Are they SAS dates or character?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 18:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325407#M72371</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-01-17T18:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325434#M72375</link>
      <description>&lt;P&gt;You can use next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp; &amp;nbsp; len = length(strip(date_var));
&amp;nbsp; &amp;nbsp;select (len);
&amp;nbsp; &amp;nbsp; &amp;nbsp; when (4) then date = mdy(01,01,input(date_var,4.));
&amp;nbsp; &amp;nbsp; &amp;nbsp; when (7) then date = input('01'||date_var, date9.);
&amp;nbsp; &amp;nbsp; &amp;nbsp; when (9) then date = input(date_var,date9.);
&amp;nbsp; &amp;nbsp; &amp;nbsp; otherwise put 'Check obs ' _N_ date_var=;
&amp;nbsp; end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then continue with DATE as sas date variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 19:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325434#M72375</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-17T19:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325438#M72378</link>
      <description>The variable diagdate is a character variable (as mentioned in the original post). Some examples of the data are as follows:&lt;BR /&gt;1963&lt;BR /&gt;1964&lt;BR /&gt;1970&lt;BR /&gt;1972&lt;BR /&gt;198&lt;BR /&gt;1980&lt;BR /&gt;1981&lt;BR /&gt;APR1993&lt;BR /&gt;DEC1991&lt;BR /&gt;FEB1995&lt;BR /&gt;JUL1980&lt;BR /&gt;MAR1993&lt;BR /&gt;MAY1995&lt;BR /&gt;NOV1973&lt;BR /&gt;NOV1994&lt;BR /&gt;OCT1979&lt;BR /&gt;01APR1993&lt;BR /&gt;01APR1997&lt;BR /&gt;01AUG1991&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jan 2017 19:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325438#M72378</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-17T19:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325440#M72379</link>
      <description>Thank you. I am trying this now. Would you mind explaining what this code is doing so that I will know for the future? Will I be getting three separate datasets?</description>
      <pubDate>Tue, 17 Jan 2017 19:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325440#M72379</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-17T19:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325442#M72380</link>
      <description>I just tried and I got an error message with the "then". Please find the message from the log below:&lt;BR /&gt;123 data diagfix1;&lt;BR /&gt;124 set disease;&lt;BR /&gt;125 len = length(strip(date02));&lt;BR /&gt;126 select (len);&lt;BR /&gt;127 when (4) then diagdate = mdy(01,01,input(date02,4.));&lt;BR /&gt;----&lt;BR /&gt;180&lt;BR /&gt;128 when (7) then diagdate = input('01'||date02, date9.);&lt;BR /&gt;----&lt;BR /&gt;180&lt;BR /&gt;129 when (9) then diagdate = input(date02,date9.);&lt;BR /&gt;----&lt;BR /&gt;180&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;&lt;BR /&gt;130 otherwise put 'Check obs ' _N_ date02=;&lt;BR /&gt;131 end;&lt;BR /&gt;132 diagtime=intck('year',diagdate,daterand);&lt;BR /&gt;133 run;&lt;BR /&gt;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Jan 2017 19:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325442#M72380</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-17T19:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325443#M72381</link>
      <description>&lt;P&gt;In&amp;nbsp;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;len &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;length&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;strip&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;date_var&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm counting number of characters in the input date variable.&lt;/P&gt;
&lt;P&gt;if variable contains year only then its length is 4.&lt;/P&gt;
&lt;P&gt;if it contains month and tear its length is 7.&lt;/P&gt;
&lt;P&gt;if its a full date in a format of ddmmmyyyy then its length is 9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for each kind of input I fill the missing part as day=01 and if need month=JAN;&lt;/P&gt;
&lt;P&gt;finally convert it to sas date variable.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 19:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325443#M72381</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-17T19:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325446#M72382</link>
      <description>&lt;P&gt;Sorry, my bug.&lt;/P&gt;
&lt;P&gt;Drop the 'then' &amp;nbsp;- code should be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; len = length(strip(date_var));
   select (len);
      when (4) date = mdy(01,01,input(date_var,4.));
      when (7) date = input('01'||date_var, date9.);
      when (9) date = input(date_var,date9.);
      otherwise put 'Check obs ' _N_ date_var=;
  end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jan 2017 19:56:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325446#M72382</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-17T19:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325448#M72383</link>
      <description>&lt;P&gt;If you want to output 3 files, then the following should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data year mmyyyy mdy;&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; select (length(strip(diagdate)));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; when (7) output mmyyyy;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; when (9) output mdy;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; otherwise output year;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 20:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325448#M72383</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-01-17T20:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325539#M72402</link>
      <description>Thank you</description>
      <pubDate>Wed, 18 Jan 2017 02:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325539#M72402</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-18T02:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325705#M72481</link>
      <description>I have a question for you regarding the length of 7 putting the character "01" since only the month and year were provided. I ended up with a diagnosis date of 2019 and a duration of -22, but not sure why. When I made it the character "01" a numeric 01, the value became missing. Do you have any explanations for this?</description>
      <pubDate>Wed, 18 Jan 2017 15:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325705#M72481</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-18T15:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325715#M72485</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt; when &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;7&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'01'&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;||&lt;/SPAN&gt;date_var&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;informat date9. accepts input as DDMMMYYYY&lt;/P&gt;
&lt;P&gt;where DD is the day (as number) of the month.&lt;/P&gt;
&lt;P&gt;I have entered &amp;nbsp;01 in order to have a valid date forma (that is the 1st day in the month)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date_var is a character type field thefore I concatenate '01' as character.&lt;/P&gt;
&lt;P&gt;You can't concatenate number to char, that is the reason of getting missing value.&lt;/P&gt;
&lt;P&gt;Have you checked you log ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 16:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/325715#M72485</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-18T16:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326011#M72561</link>
      <description>Thank you for the explanation. I don't recall seeing anything in the log, but I will check again. Doesn't the input command change the variable from character to numeric?</description>
      <pubDate>Thu, 19 Jan 2017 15:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326011#M72561</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-19T15:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326124#M72585</link>
      <description>I just checked the log and it did not give me any error messages. When I looked at the diagnosis date that was created, for 50 of the patients it is giving me a diagnosis date of 01mmm2019. Why 2019? I end up with a negative time from diagnosis. The years provided in the date variable range from 1973-1995. I am not sure why the code gives a year of 2019 for these year ranges.</description>
      <pubDate>Thu, 19 Jan 2017 20:59:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326124#M72585</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-19T20:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326133#M72588</link>
      <description>&lt;P&gt;Its difficult to know why you got year 2019.&lt;/P&gt;
&lt;P&gt;please post again &lt;STRONG&gt;your full code&lt;/STRONG&gt; +&lt;STRONG&gt; sample of input rows that make you truble&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 21:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326133#M72588</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-19T21:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326144#M72591</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/107488"&gt;@PaulaC&lt;/a&gt;: Sorry to hear that you're still having problems. Seeing your code would definitely help as well as seeing the dates (as entered in the raw data) for the 50 people in question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following definitely worked for me given your sample data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data year mmyyyy mdy;
  input date02 $9.;
  format diagdate date9.;
  select (length(strip(date02)));
      when (4) do;
                 diagdate = mdy(01,01,input(date02,4.));
                 output year;
               end;
      when (7) do;
                 diagdate = input('01'||date02, date9.);
                 output mmyyyy;
               end;
      when (9) do;
                 diagdate = input(date02,date9.);
                 output mdy;
               end;
      otherwise put 'Check obs ' _N_ date02=;
  end;
  cards;
1963
1964
1970
1972
198
1980
1981
APR1993
DEC1991
FEB1995
JUL1980
MAR1993
MAY1995
NOV1973
NOV1994
OCT1979
01APR1993
01APR1997
01AUG1991
;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 22:40:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326144#M72591</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-01-19T22:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326169#M72599</link>
      <description>&lt;P&gt;Please find the output with the 2019 diagnosis date as well as the negative diagnosis time in the attached excel document. &amp;nbsp;Other than the diagdate and diagtime, the other variables are the input variables with mock data. &amp;nbsp;The code I used is below.&lt;/P&gt;&lt;P&gt;data merge;&lt;BR /&gt;merge bchist demog;&lt;BR /&gt;by subject;&lt;BR /&gt;where strip(trt) ne "001";&lt;BR /&gt;len = length(strip(date02));&lt;BR /&gt;select (len);&lt;BR /&gt;when (4) diagdate = mdy(06,15,input(date02,4.));&lt;BR /&gt;when (7) diagdate = input("15"||date02, date9.);&lt;BR /&gt;when (9) diagdate = input(date02,date9.);&lt;BR /&gt;otherwise put 'Check obs ' _N_ date02=;&lt;BR /&gt;end;&lt;BR /&gt;format diagdate date9.;&lt;BR /&gt;diagtime=intck('year',diagdate,daterand);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you need any further information. &amp;nbsp;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 03:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326169#M72599</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-20T03:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326179#M72604</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/107488"&gt;@PaulaC&lt;/a&gt;: You have embedded spaces in your data. The following should correct for that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data year mmyyyy mdy;
  input date02 $12.;
  format diagdate date9.;
  date02=strip(date02);
  select (length(strip(date02)));
      when (4) do;
                 diagdate = mdy(06,05,input(date02,4.));
                 output year;
               end;
      when (7) do;
                 diagdate = input('15'||date02, date9.);
                 output mmyyyy;
               end;
      when (9) do;
                 diagdate = input(date02,date9.);
                 output mdy;
               end;
      otherwise put 'Check obs ' _N_ date02=;
  end;
  cards;
1963
1964
1970
1972
198
1980
1981
APR1993
DEC1991
FEB1995
JUL1980
MAR1993
MAY1995
NOV1973
NOV1994
OCT1979
01APR1993
01APR1997
01AUG1991
  OCT1991
  OCT1991
  OCT1991
  OCT1991
  NOV1979
  NOV1979
  NOV1979
  NOV1979
  NOV1979
  NOV1979
  JAN1993
  JAN1993
  JAN1993
  JAN1993
  JUN1980
  JUN1980
  JUN1980
  JUN1980
  MAR1995
  MAR1995
  MAR1995
  MAR1995
  MAR1995
  MAR1995
  MAR1995
 DEC1973
 DEC1973
 DEC1973
 DEC1973
 DEC1973
 DEC1973
 DEC1973
 MAY1993
 MAY1993
 MAY1993
 MAY1993
 MAY1993
  MAR1995
  MAR1995
  MAR1995
  MAR1995
  MAR1995
  MAR1995
  MAR1995
  MAR1995
  MAR1995
  OCT1994
  OCT1994
  OCT1994
  OCT1994
;
&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 05:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326179#M72604</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-01-20T05:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326199#M72614</link>
      <description>&lt;P&gt;Pay attention:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;added the next line to the code, just before the&amp;nbsp;&lt;STRONG&gt;select&lt;/STRONG&gt; statement:&lt;/P&gt;
&lt;PRE&gt;date02=strip(date02);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You can use also function&amp;nbsp;&lt;STRONG&gt;compress()&lt;/STRONG&gt; or&amp;nbsp;&lt;STRONG&gt;left()&lt;/STRONG&gt; instead&amp;nbsp;&lt;STRONG&gt;strip&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 08:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326199#M72614</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-20T08:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting data based on date format type</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326286#M72638</link>
      <description>Thank you very much. I will definitely try that. Appreciate your help.&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Jan 2017 14:44:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-data-based-on-date-format-type/m-p/326286#M72638</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-20T14:44:34Z</dc:date>
    </item>
  </channel>
</rss>

