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.
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.
HTH,
Art
> Hello,
>
> 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.
> 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.
>
> Before I can analyze average pay by rank, rank &
> gender, rank & 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.
>
>
> **getting only dec31 info into a dataset;
>
> roc sort data=allinfo; by armyid date;
>
> data yrend; set allinfo;
> array dates {3} date01-date03;
> if _n_ eq 1 then do;
> date01='31dec07'd;
> ate02='31dec08'd;
> date03='31dec09'd;
>
>
> cendate=dates{i};
> te eq cendate
> then output;
> d;
>
> retain date01-date03;
> format todate date cendate date9.;
> drop date01-date03;
>
> end;