<?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: Substr YYYY and MM from Sas date YYYYMM (edited) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343770#M78941</link>
    <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. You're right. As a result of this experiment, I realized that I have old and young folks with a cancer hospitalized between 1995-2013 with age range of 7-107yrs. Code below shows how I tested and variable "test" has only 0,1 values depending whether they were hospitalized before or after their birthday.&lt;/P&gt;&lt;P&gt;2. Suggested formats didn't work but either substr and substrn identically worked out.&lt;/P&gt;&lt;P&gt;3. Critical thinking was required to question, perhaps folks I have here might just be old vs very young (7-107yrs).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I select two answers for SOLUTIONS? I truly appreciate your help indeed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dy = substrn(left(dob), 1, 4);
dm = substrn(left(dob), 5, 2);
difference=hospitalized_year-dy;
cage=input(AGE,3.);
test=difference-cage;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 Mar 2017 16:33:17 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2017-03-23T16:33:17Z</dc:date>
    <item>
      <title>Substr YYYY and MM from Sas date YYYYMM (edited)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343568#M78882</link>
      <description>&lt;P&gt;I have a SAS date in format of YYYYMM as shown in my viewtable below. This YYYYMM "dob" variable is the truncation of original 8 digit SAS date for confidentiality purpose. So, I don't know how it originally looked like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7916i0427BC9ACA88F025/image-size/medium?v=1.0&amp;amp;px=-1" alt="my data view" title="my data view" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final result that I would like to have is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7921i7ACD3775EA3133D1/image-size/original?v=1.0&amp;amp;px=-1" alt="Aiming to come up:" title="Aiming to come up:" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried several different ways and some of my unsuccessful attempts are here:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dob1 = put(dob, YYMMN6.); &lt;BR /&gt;dob1 = input(dob, yymmn6.);
dy = substr(dob,5,4);
dm = substr(dob,7,2);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Jagadishkatam's suggested code below was resulted as shown:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dob1=put(dob,yymmn6.);
dy = year(dob1);
dm = month(dob1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Result of above code:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7922iC3294BD068A887B3/image-size/original?v=1.0&amp;amp;px=-1" alt="results2.png" title="results2.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't tried substrn yet. I will soon.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This problem was &lt;A href="https://communities.sas.com/t5/SAS-Procedures/Sas-date-to-format-YYYYMM/m-p/127704#M34913" target="_self"&gt;previously discussed &lt;/A&gt;here. But it didn't work with my SAS9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hints are appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 11:40:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343568#M78882</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-23T11:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343571#M78884</link>
      <description>&lt;P&gt;We could use the year() and month() functions as below&lt;BR /&gt;&lt;BR /&gt;dy=year(dob);&lt;BR /&gt;dm=month(dob);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: At the moment the date seem not right like the DOB of 189005 when converted to date9 format it is 23Jun2477. so it is a strange date. but if it is only for example then it is fine.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 02:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343571#M78884</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-03-23T02:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343575#M78886</link>
      <description>&lt;P&gt;Hi Jagadishkatam,&lt;/P&gt;&lt;P&gt;The solution you suggested was resulted as shown below. Your observation using data9. is very interesting. it's not just for display. I really have to figure out this yyyymm date variable. Current yyyymm date I have is the result of a truncation of 8 digit SAS date, I think.&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7917i5AB9D0835A801055/image-size/original?v=1.0&amp;amp;px=-1" alt="output" title="output" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 02:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343575#M78886</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-23T02:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343576#M78887</link>
      <description>you could try the &lt;BR /&gt;&lt;BR /&gt;using the put(dob,yymmn6.) it does retrieve the year and month. I am not sure what is the exact issue you have.</description>
      <pubDate>Thu, 23 Mar 2017 02:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343576#M78887</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-03-23T02:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343578#M78889</link>
      <description>&lt;P&gt;What does 189005 mean in terms of a date?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What part is the year, day and month?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try SUBSTR&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;N&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;year = substrn(old_var, 1, 4);
month = substrn(old_var, 5, 2);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Or&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Date_type =input( put(old_var, 6.), yymmn6.);
Year=year(date_type);
Month = month(date_type);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;If this doesn't work post the exact code and log.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 03:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343578#M78889</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-23T03:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343596#M78896</link>
      <description>&lt;P&gt;It would be helpful to have an example of the math. &amp;nbsp;For example, show what YYYY and MM look like, an original DOB, and what the final result would look like after subtracting them.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 05:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343596#M78896</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-23T05:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343672#M78918</link>
      <description>just edited my original post as per your suggestion</description>
      <pubDate>Thu, 23 Mar 2017 11:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343672#M78918</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-23T11:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343673#M78919</link>
      <description>Your code did the trick to a month. But years are still in 1809 something range. I will post exact details when i get back to office. I have a feeling that yours is getting close.</description>
      <pubDate>Thu, 23 Mar 2017 11:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343673#M78919</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-23T11:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM (edited)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343695#M78923</link>
      <description>&lt;P&gt;If I have the question right (and I'm not really sure about that), you are starting with A and looking to calculate B and C.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Aiming to come up:" alt="Aiming to come up:" src="https://communities.sas.com/t5/image/serverpage/image-id/7921i7ACD3775EA3133D1/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's the case, the formulas are straightforward &lt;FONT color="#ff0000"&gt;(and now corrected)&lt;/FONT&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;B = int(&lt;FONT color="#ff0000"&gt;A&lt;/FONT&gt;/100);&lt;/P&gt;
&lt;P&gt;C = mod(&lt;FONT color="#ff0000"&gt;A&lt;/FONT&gt;, 100);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Somehow I get the feeling that I'm leaving out a key piece of the question though.&amp;nbsp; I can't draw the link between this table and your original table.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 15:06:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343695#M78923</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-23T15:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343729#M78930</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;I tried your first code with and without left.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Reeza1*/
data x1; set x;
year = substrn(left(dob), 1, 4);
month = substrn(left(dob), 5, 2);
run; 
/*Reeza2*/
data feb.gro_id1; set feb.gro_id;
Date_type =input( put(dob, 6.), yymmn6.);
Year=year(date_type);
Month = month(date_type);
run; 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The corresponding results in viewtable are:&lt;/P&gt;&lt;P&gt;Reeza1:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7925i957B122F2E4361A6/image-size/original?v=1.0&amp;amp;px=-1" alt="Reeza1" title="Reeza1" border="0" /&gt;&lt;/P&gt;&lt;P&gt;Reeza2:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7926i39ECC4EA8F559A99/image-size/original?v=1.0&amp;amp;px=-1" alt="reeza2" title="reeza2" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 14:39:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343729#M78930</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-23T14:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM (edited)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343736#M78932</link>
      <description>&lt;P&gt;Hi Respected,&lt;/P&gt;&lt;P&gt;I am starting with below. Date is truncated for confidentiality concern. So I have this 6 digit SAS date.&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7927i7F0D2969FC4814D0/image-size/original?v=1.0&amp;amp;px=-1" alt="respected ad.png" title="respected ad.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;I tried your code as:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;year=substr(left(dob),1,4);
month=substr(left(dob),5,2);
B = int(year/100);
C = mod(year, 100);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;That is resulted in:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7928i1CF04E307938117D/image-size/original?v=1.0&amp;amp;px=-1" alt="respected advisor.png" title="respected advisor.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any alternatives?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 14:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343736#M78932</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-23T14:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM (edited)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343745#M78934</link>
      <description>&lt;P&gt;Just mixing and matching names ... should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;year = int(dob/100);&lt;/P&gt;
&lt;P&gt;month = mod(dob, 100);&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 15:04:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343745#M78934</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-23T15:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM (edited)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343748#M78935</link>
      <description>I still have 1890, 1898 sort of years after this.</description>
      <pubDate>Thu, 23 Mar 2017 15:11:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343748#M78935</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-23T15:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM (edited)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343751#M78937</link>
      <description>&lt;P&gt;If you are getting DOB in the 1800's then either you have some really old people or the process that created that field did something wrong. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most likely it assumed the wrong century for a date string with a two digit year. &amp;nbsp;If you cannot correct that then you will need to do the best you can to fix the DOB after the fact. &amp;nbsp;If you have other information that could lead you believe that the 1890 is unreasonable but that 1990 is reasonable for that person then just add 100 years to the DOB.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 15:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343751#M78937</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-23T15:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM (edited)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343762#M78940</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;Look at the first picture you posted. It looks like 1890. If it's not supposed to be 1890 what is it supposed to be. According to what I see, the code looks like it ran correctly. Either&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Your dates are in some other format than you've specified. Did you import this data from Excel, from a date field&lt;/P&gt;
&lt;P&gt;2. Your dates are wrong&lt;/P&gt;
&lt;P&gt;3. Dates are correct and you have some really old people.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 15:47:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343762#M78940</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-23T15:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Substr YYYY and MM from Sas date YYYYMM (edited)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343770#M78941</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. You're right. As a result of this experiment, I realized that I have old and young folks with a cancer hospitalized between 1995-2013 with age range of 7-107yrs. Code below shows how I tested and variable "test" has only 0,1 values depending whether they were hospitalized before or after their birthday.&lt;/P&gt;&lt;P&gt;2. Suggested formats didn't work but either substr and substrn identically worked out.&lt;/P&gt;&lt;P&gt;3. Critical thinking was required to question, perhaps folks I have here might just be old vs very young (7-107yrs).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I select two answers for SOLUTIONS? I truly appreciate your help indeed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dy = substrn(left(dob), 1, 4);
dm = substrn(left(dob), 5, 2);
difference=hospitalized_year-dy;
cage=input(AGE,3.);
test=difference-cage;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Mar 2017 16:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substr-YYYY-and-MM-from-Sas-date-YYYYMM-edited/m-p/343770#M78941</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-03-23T16:33:17Z</dc:date>
    </item>
  </channel>
</rss>

