<?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 Convert string to date variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Convert-string-to-date-variable/m-p/577642#M13255</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to SAS !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a 6 digit string variable which describes a date period e.g. 010111 equal too 01jan2011. My dataset also includes dates from the 20 century e.g. 010199 equal to 01jan1999.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I first of all convert my string variable into a sas date?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And how do I deal with the two digit year so I dont ends up&amp;nbsp;with a year that looks like 2090?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards Frank&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>Wed, 31 Jul 2019 10:14:42 GMT</pubDate>
    <dc:creator>frakje</dc:creator>
    <dc:date>2019-07-31T10:14:42Z</dc:date>
    <item>
      <title>Convert string to date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-string-to-date-variable/m-p/577642#M13255</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to SAS !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a 6 digit string variable which describes a date period e.g. 010111 equal too 01jan2011. My dataset also includes dates from the 20 century e.g. 010199 equal to 01jan1999.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I first of all convert my string variable into a sas date?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And how do I deal with the two digit year so I dont ends up&amp;nbsp;with a year that looks like 2090?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards Frank&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>Wed, 31 Jul 2019 10:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-string-to-date-variable/m-p/577642#M13255</guid>
      <dc:creator>frakje</dc:creator>
      <dc:date>2019-07-31T10:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string to date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-string-to-date-variable/m-p/577645#M13256</link>
      <description>&lt;P&gt;Hope your year will be from 2000 on wards. Here is one way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   str = '010111';
day = input(substr(str,1,2),8.);
mon = input(substr(str,3,2),8.);
year = input(cats('20',substr(str,5,2)),8.);
put day = mon = year =;
mydate = mdy(mon, day,year);
put mydate = date10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 08:59:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-string-to-date-variable/m-p/577645#M13256</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2019-07-30T08:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string to date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-string-to-date-variable/m-p/577680#M13259</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input string :$6.;
datalines;
010111
010199
010180
010170
010160
010150
010140
010130
010120
;

data want;
set have;
date_num = input(string,ddmmyy6.);
format date_num yymmddd10.;
run;

proc options option=yearcutoff;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Set the yearcutoff= option to a value that's appropriate for you. FYI, the last part of the log:&lt;/P&gt;
&lt;PRE&gt;47         proc options option=yearcutoff;
48         run;

    SAS (r) Proprietary Software Release 9.4  TS1M5

 YEARCUTOFF=1926   Specifies the first year of a 100-year span that is used by date informats and functions to read a two-digit 
                   year.
&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jul 2019 11:36:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-string-to-date-variable/m-p/577680#M13259</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-30T11:36:48Z</dc:date>
    </item>
  </channel>
</rss>

