Help using Base SAS procedures

pulling out specific dates from data

Reply
Occasional Contributor
Posts: 10

pulling out specific dates from data

Hello,

I have a data set that contains information such as

ID DATE PAY EMP_GRADE RANK
0001 12/01/07 24.32 O-2 GEN


Each employee (ID) has observations that are daily for 2 years. The pay, grade and rank (using RETAIN) have been filled in over the entire 2 year period.



I need to pull out a specific date (Dec 31st for 2007, 2008, 2009) for each employee, so that I end with three records for each employee that include the variables ID, Pay, Grade and Rank.


ID DATE PAY EMP_GRADE RANK
0001 12/31/07 24.32 E-2 LT
0001 12/31/08 24.32 O-2 LT
0001 12/31/09 24.32 O-2 GEN
0012 12/31/07 24.32 O-2 MJR


I then have to give a frequence report for each year by the grade, counting either Enlisted (E) or Officer (O). I think I need to use a PROC FREQ, but again, not sure how to get from point A to point B. I'd really appreciate any help and insight!

Thanks in advace
SAS Super FREQ
Posts: 8,866

Re: pulling out specific dates from data

Hi:
The DATE variable in SASHELP.PRICEDATA is a numeric variable and the days are all on the 1st of the month, but the concept in the program below still applies. The first report uses the MONTH and DAY functions to get out the observations falling on 12/1 of any year. The second report uses a third condition for an additional criteria of REGION=3 -- since the WHERE statement selects observations BEFORE the data gets to PROC FREQ, this may be one way for you to accomplish your reporting.

cynthia
[pre]
proc freq data=sashelp.pricedata;
title '1) Only Counting Based on Month and Day';
where month(date) = 12 and day(date) = 1;
tables date*region /list;
format date mmddyy10.;
run;

proc freq data=sashelp.pricedata;
title '2) Only Counting Based on Region, Month and Day';
where month(date) = 12 and day(date) = 1 and Region=3;
tables date*region
ProductLine*date/list;
format date mmddyy10.;
run;
[/pre]
Occasional Contributor
Posts: 10

Re: pulling out specific dates from data

Posted in reply to Cynthia_sas
Thank you for your help! This was great!
Ask a Question
Discussion stats
  • 2 replies
  • 238 views
  • 0 likes
  • 2 in conversation