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
SAS Super FREQ
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!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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