<?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 pulling out specific dates of a dataset for 3 years for each employee in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/pulling-out-specific-dates-of-a-dataset-for-3-years-for-each/m-p/33883#M8206</link>
    <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I'm new to programing and am having lots o' troubles.  I'd appreciate any help.  I have a dataset that has a daily observation for 3 years, 2007, 2008 and 2009 for each armyid.  They have a grade, rank and pay, which change over the years.  &lt;BR /&gt;
I need to GET RID of all dates except for /12/31/2007, 12/31/2008 and 12/31/2009, so essentially, if someone was in for all three years, they would have 3 obs for their armyid. &lt;BR /&gt;
&lt;BR /&gt;
Before I can analyze average pay by rank, rank &amp;amp; gender, rank &amp;amp; race, (proc freq or proc means?) I first have to get rid of all the other observations.  I've tried the code below, but i don't get all 3 observations for some of the armyids. &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
**getting only dec31 info into a dataset;&lt;BR /&gt;
 &lt;BR /&gt;
proc sort data=allinfo; by armyid date;&lt;BR /&gt;
&lt;BR /&gt;
data yrend; set allinfo;&lt;BR /&gt;
array dates {3} date01-date03;&lt;BR /&gt;
   if _n_ eq 1 then do;&lt;BR /&gt;
             date01='31dec07'd;&lt;BR /&gt;
         date02='31dec08'd;&lt;BR /&gt;
         date03='31dec09'd;          &lt;BR /&gt;
end;&lt;BR /&gt;
                   &lt;BR /&gt;
   do i=1 to 3;&lt;BR /&gt;
                cendate=dates{i}; &lt;BR /&gt;
          if  date eq cendate &lt;BR /&gt;
         then output;&lt;BR /&gt;
       end;&lt;BR /&gt;
&lt;BR /&gt;
   retain date01-date03;&lt;BR /&gt;
    format todate date cendate date9.;&lt;BR /&gt;
     drop date01-date03;&lt;BR /&gt;
run;&lt;BR /&gt;
end;</description>
    <pubDate>Sun, 20 Mar 2011 20:33:09 GMT</pubDate>
    <dc:creator>lgtea57</dc:creator>
    <dc:date>2011-03-20T20:33:09Z</dc:date>
    <item>
      <title>pulling out specific dates of a dataset for 3 years for each employee</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/pulling-out-specific-dates-of-a-dataset-for-3-years-for-each/m-p/33883#M8206</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I'm new to programing and am having lots o' troubles.  I'd appreciate any help.  I have a dataset that has a daily observation for 3 years, 2007, 2008 and 2009 for each armyid.  They have a grade, rank and pay, which change over the years.  &lt;BR /&gt;
I need to GET RID of all dates except for /12/31/2007, 12/31/2008 and 12/31/2009, so essentially, if someone was in for all three years, they would have 3 obs for their armyid. &lt;BR /&gt;
&lt;BR /&gt;
Before I can analyze average pay by rank, rank &amp;amp; gender, rank &amp;amp; race, (proc freq or proc means?) I first have to get rid of all the other observations.  I've tried the code below, but i don't get all 3 observations for some of the armyids. &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
**getting only dec31 info into a dataset;&lt;BR /&gt;
 &lt;BR /&gt;
proc sort data=allinfo; by armyid date;&lt;BR /&gt;
&lt;BR /&gt;
data yrend; set allinfo;&lt;BR /&gt;
array dates {3} date01-date03;&lt;BR /&gt;
   if _n_ eq 1 then do;&lt;BR /&gt;
             date01='31dec07'd;&lt;BR /&gt;
         date02='31dec08'd;&lt;BR /&gt;
         date03='31dec09'd;          &lt;BR /&gt;
end;&lt;BR /&gt;
                   &lt;BR /&gt;
   do i=1 to 3;&lt;BR /&gt;
                cendate=dates{i}; &lt;BR /&gt;
          if  date eq cendate &lt;BR /&gt;
         then output;&lt;BR /&gt;
       end;&lt;BR /&gt;
&lt;BR /&gt;
   retain date01-date03;&lt;BR /&gt;
    format todate date cendate date9.;&lt;BR /&gt;
     drop date01-date03;&lt;BR /&gt;
run;&lt;BR /&gt;
end;</description>
      <pubDate>Sun, 20 Mar 2011 20:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/pulling-out-specific-dates-of-a-dataset-for-3-years-for-each/m-p/33883#M8206</guid>
      <dc:creator>lgtea57</dc:creator>
      <dc:date>2011-03-20T20:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: pulling out specific dates of a dataset for 3 years for each employee</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/pulling-out-specific-dates-of-a-dataset-for-3-years-for-each/m-p/33884#M8207</link>
      <description>Your code is more complicated than it has to be, but it will work.  If you aren't getting all three records then I would guess that you don't have all three records for each army id.&lt;BR /&gt;
&lt;BR /&gt;
You get a warning because you include a variable in your format statement called todate that you never use and, after the program has run, you get an error because of your last line (i.e., an end statement after the run statement).  Just delete that last line (i.e., end;) and you won't get the error.&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art&lt;BR /&gt;
&amp;gt; Hello,&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I'm new to programing and am having lots o' troubles.&lt;BR /&gt;
&amp;gt; I'd appreciate any help.  I have a dataset that has&lt;BR /&gt;
&amp;gt; a daily observation for 3 years, 2007, 2008 and 2009&lt;BR /&gt;
&amp;gt; for each armyid.  They have a grade, rank and pay,&lt;BR /&gt;
&amp;gt;  which change over the years.  &lt;BR /&gt;
&amp;gt; need to GET RID of all dates except for /12/31/2007,&lt;BR /&gt;
&amp;gt; 12/31/2008 and 12/31/2009, so essentially, if&lt;BR /&gt;
&amp;gt; someone was in for all three years, they would have&lt;BR /&gt;
&amp;gt;  3 obs for their armyid. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Before I can analyze average pay by rank, rank &amp;amp;&lt;BR /&gt;
&amp;gt; gender, rank &amp;amp; race, (proc freq or proc means?) I&lt;BR /&gt;
&amp;gt; first have to get rid of all the other observations.&lt;BR /&gt;
&amp;gt; I've tried the code below, but i don't get all 3&lt;BR /&gt;
&amp;gt;  observations for some of the armyids. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; **getting only dec31 info into a dataset;&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt; roc sort data=allinfo; by armyid date;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; data yrend; set allinfo;&lt;BR /&gt;
&amp;gt; array dates {3} date01-date03;&lt;BR /&gt;
&amp;gt;    if _n_ eq 1 then do;&lt;BR /&gt;
&amp;gt;           date01='31dec07'd;&lt;BR /&gt;
&amp;gt; ate02='31dec08'd;&lt;BR /&gt;
&amp;gt;          date03='31dec09'd;          &lt;BR /&gt;
&amp;gt;                 &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;                 cendate=dates{i}; &lt;BR /&gt;
&amp;gt; te eq cendate &lt;BR /&gt;
&amp;gt;          then output;&lt;BR /&gt;
&amp;gt; d;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;    retain date01-date03;&lt;BR /&gt;
&amp;gt;  format todate date cendate date9.;&lt;BR /&gt;
&amp;gt;     drop date01-date03;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; end;</description>
      <pubDate>Sun, 20 Mar 2011 21:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/pulling-out-specific-dates-of-a-dataset-for-3-years-for-each/m-p/33884#M8207</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-03-20T21:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: pulling out specific dates of a dataset for 3 years for each employee</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/pulling-out-specific-dates-of-a-dataset-for-3-years-for-each/m-p/33885#M8208</link>
      <description>How about this?&lt;BR /&gt;
&lt;BR /&gt;
data yrend; set allinfo;&lt;BR /&gt;
if date in ('31dec07'd, '31dec08'd, '31dec09'd);&lt;BR /&gt;
run;</description>
      <pubDate>Mon, 21 Mar 2011 11:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/pulling-out-specific-dates-of-a-dataset-for-3-years-for-each/m-p/33885#M8208</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2011-03-21T11:00:19Z</dc:date>
    </item>
  </channel>
</rss>

