BookmarkSubscribeRSS Feed
lgtea57
Calcite | Level 5
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
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
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]
lgtea57
Calcite | Level 5
Thank you for your help! This was great!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1341 views
  • 0 likes
  • 2 in conversation