<?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: How to caculate years and find specific variable in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372707#M2864</link>
    <description>&lt;P&gt;Comparing dates in strings will most likely not give the expected result. The subetting if-statement ist misplaced, move it below the input statement.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jul 2017 11:25:48 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2017-07-03T11:25:48Z</dc:date>
    <item>
      <title>How to caculate years and find specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372405#M2858</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I need to find retirees who have worked for 25 or more years for the airline company. If you want to, you can use December 31, 2016 as a point of reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data step is :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hw3.retirees25;
infile "&amp;amp;path/retirees2017.txt" dlm=' ';
length LastName $ 10 FirstName $ 11 HD $ 10;
input Department$12. HD$ ES ID$ LastName$ FirstName$;
label HD="Hire Date"
         ES="Ending Salary"
         ID="EmployeeID";
years=int(yrdif(HD,12/31/2016,'ACT/365'));
where years &amp;gt;= 25;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it shows:&amp;nbsp;&lt;SPAN&gt;ERROR: No input data sets available for WHERE statement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone help me how I could find those people work over 25 years?&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 10:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372405#M2858</guid>
      <dc:creator>ydu180</dc:creator>
      <dc:date>2017-07-01T10:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to caculate years and find specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372406#M2859</link>
      <description>&lt;P&gt;When you are reading from raw data (INFILE / INPUT), the WHERE statement is illegal. &amp;nbsp;Just change WHERE to IF.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 10:49:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372406#M2859</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-01T10:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to caculate years and find specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372413#M2860</link>
      <description>&lt;PRE&gt;'31Dec2016'd&lt;/PRE&gt;
&lt;P&gt;You specify dates in SAS as a date literal, see above. Replace your date in the INTCK function with a date in the format above.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 13:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372413#M2860</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-01T13:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to caculate years and find specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372533#M2861</link>
      <description>&lt;PRE&gt;First of all . Function yrdif() require DATE type arguments.  But yours is character type.  


data hw3.retirees25;
infile "&amp;amp;path/retirees2017.txt" dlm=' ';
length LastName $ 10 FirstName $ 11 HD $ 10;
input Department$12. HD  : mmddyy12.  ES ID$ LastName$ FirstName$;
label HD="Hire Date"
         ES="Ending Salary"
         ID="EmployeeID";
years=int(yrdif(HD,'31dec2016'd,'ACT/365'));
if  years &amp;gt;= 25;
run;   &lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Jul 2017 13:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372533#M2861</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-07-02T13:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to caculate years and find specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372563#M2862</link>
      <description>&lt;P&gt;After I changed that, I could not print out in the next part. I must let the date shows in character way, it is the original one I did not asked to change that. So is there another way, I could caculate years between them and only show years &amp;gt;= 25?&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 15:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372563#M2862</guid>
      <dc:creator>ydu180</dc:creator>
      <dc:date>2017-07-02T15:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to caculate years and find specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372582#M2863</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hw3.retirees25;
   infile "&amp;amp;path/retirees2017.txt" dlm=' ';
   length LastName $ 10 FirstName $ 11 HD $ 10;
   if HD &amp;lt;= "12/31/1991";
   input Department$12. HD$ ES ID$ LastName$ FirstName$; 
   label HD="Hire Date"
         ES="Ending Salary"
         ID="EmployeeID";
   format ES comma7.; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried another way, but it still show all my observations.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 16:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372582#M2863</guid>
      <dc:creator>ydu180</dc:creator>
      <dc:date>2017-07-02T16:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to caculate years and find specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372707#M2864</link>
      <description>&lt;P&gt;Comparing dates in strings will most likely not give the expected result. The subetting if-statement ist misplaced, move it below the input statement.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 11:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372707#M2864</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-07-03T11:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to caculate years and find specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372710#M2865</link>
      <description>&lt;P&gt;So far, you're doing the right thing. &amp;nbsp;The way you print a date in as "characters" is to apply a format. &amp;nbsp;This statement could become part of the DATA step, or it could become part of the next step that prints the data (either way is fine):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format hd&amp;nbsp;mmddyy10.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many other date formats you can choose from. &amp;nbsp;Here are just a few samples:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format hd date9.;&lt;/P&gt;
&lt;P&gt;format hd&amp;nbsp;yymmdds10.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 11:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-caculate-years-and-find-specific-variable/m-p/372710#M2865</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-03T11:33:49Z</dc:date>
    </item>
  </channel>
</rss>

