<?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 Process irregular date time in SAS in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Process-irregular-date-time-in-SAS/m-p/684114#M24194</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I am new to SAS have a question regarding the processing of date time in SAS. My data variable is formatted as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1920/11/1 0:00	
1920/11/21 0:00
1920/5/15 0:00
1920/8/27 0:00	
1921/7/14 0:00
1921/7/26 0:00	
1921/8/2 0:00	
1922/2/12 0:00	
1922/2/22 0:00	
1923/11/1 0:00	
1923/12/3 0:00	
1923/2/13 0:00&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So they are of irregular lengths and as I understand they do not fit any of the SAS built-in format. They do not have "0"s before or behind the single-digit months or dates.&lt;/P&gt;&lt;P&gt;The result I am expecting is to 1) get rid of the last 5 digits of the clock time; 2) transform the date variable into standard format and then SAS date values (days comparing with Jan/01/1960) and 3) generate 2 variables that display the month and day of the date variable in readable format (but still calculatable).&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Original date variable:&amp;nbsp;&lt;CODE class=" language-sas"&gt;1921/7/14 0:00&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Converted into 1921/07/14 which is about negative sth SAS date value&lt;/P&gt;&lt;P&gt;monthvar: 1921/07&lt;/P&gt;&lt;P&gt;datevar: 1921/07/21&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not really sure how to achieve that, especially with the irregular format. Please help! Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ginny Han&lt;/P&gt;</description>
    <pubDate>Wed, 16 Sep 2020 03:38:56 GMT</pubDate>
    <dc:creator>Ginny_Han</dc:creator>
    <dc:date>2020-09-16T03:38:56Z</dc:date>
    <item>
      <title>Process irregular date time in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Process-irregular-date-time-in-SAS/m-p/684114#M24194</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I am new to SAS have a question regarding the processing of date time in SAS. My data variable is formatted as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1920/11/1 0:00	
1920/11/21 0:00
1920/5/15 0:00
1920/8/27 0:00	
1921/7/14 0:00
1921/7/26 0:00	
1921/8/2 0:00	
1922/2/12 0:00	
1922/2/22 0:00	
1923/11/1 0:00	
1923/12/3 0:00	
1923/2/13 0:00&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So they are of irregular lengths and as I understand they do not fit any of the SAS built-in format. They do not have "0"s before or behind the single-digit months or dates.&lt;/P&gt;&lt;P&gt;The result I am expecting is to 1) get rid of the last 5 digits of the clock time; 2) transform the date variable into standard format and then SAS date values (days comparing with Jan/01/1960) and 3) generate 2 variables that display the month and day of the date variable in readable format (but still calculatable).&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Original date variable:&amp;nbsp;&lt;CODE class=" language-sas"&gt;1921/7/14 0:00&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Converted into 1921/07/14 which is about negative sth SAS date value&lt;/P&gt;&lt;P&gt;monthvar: 1921/07&lt;/P&gt;&lt;P&gt;datevar: 1921/07/21&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not really sure how to achieve that, especially with the irregular format. Please help! Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ginny Han&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 03:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Process-irregular-date-time-in-SAS/m-p/684114#M24194</guid>
      <dc:creator>Ginny_Han</dc:creator>
      <dc:date>2020-09-16T03:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Process irregular date time in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Process-irregular-date-time-in-SAS/m-p/684118#M24195</link>
      <description>&lt;P&gt;Are you asking how to change your existing strings into date values?&amp;nbsp; If so you are looking for an INFORMAT, not a format.&amp;nbsp; Since you don't care about the time of day part just ignore it.&amp;nbsp; Once you have a date value you can use any of the many SAS formats that display dates. Like YYMMDD.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  date=input(scan(date_string,1,' '),yymmdd10.);
  format date yymmdd10. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs      date_string            date

  1    1920/11/1 0:00     1920-11-01
  2    1920/11/21 0:00    1920-11-21
  3    1920/5/15 0:00     1920-05-15
  4    1920/8/27 0:00     1920-08-27
  5    1921/7/14 0:00     1921-07-14
  6    1921/7/26 0:00     1921-07-26
  7    1921/8/2 0:00      1921-08-02
  8    1922/2/12 0:00     1922-02-12
  9    1922/2/22 0:00     1922-02-22
 10    1923/11/1 0:00     1923-11-01
 11    1923/12/3 0:00     1923-12-03
 12    1923/2/13 0:00     1923-02-13
&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Sep 2020 04:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Process-irregular-date-time-in-SAS/m-p/684118#M24195</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-16T04:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Process irregular date time in SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Process-irregular-date-time-in-SAS/m-p/684499#M24211</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;Thank you very much for your swift solution. It worked perfectly. Never considered the possibility of using the -scan- function. Thought I should start with eliminating some digits from the end.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 04:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Process-irregular-date-time-in-SAS/m-p/684499#M24211</guid>
      <dc:creator>Ginny_Han</dc:creator>
      <dc:date>2020-09-17T04:22:01Z</dc:date>
    </item>
  </channel>
</rss>

