BookmarkSubscribeRSS Feed
venkatesh
Calcite | Level 5
Hi all.,

I Have a data set with variable like

empid, salary, salary2, date mmddyy10.;
101 15000 16000 10/11/2006
101 20000 25000 10/12/2006
101 5000 2500 10/12/2006
101 15600 18000 11/09/2006
101 16000 12500 11/12/2006

....
....
...

here i required the output as

101 40000 43500 10/11/2006
101 31600 30500 11/09/2006
.....
....

according to the month wise need to add salary1 and salary2 variables and displayed at startingdate of the each observation.(here month 10 two times and month 11 two times....i have nearly 3000 records....in a single year...)

i can use all the three Base Sas, Di Studio and Enterprise Guide.....

Help would be a great....

Venkatesh.
2 REPLIES 2
deleted_user
Not applicable
Try this...

This code reads in the data, but notice i create a month variable to be the month of the date.


data emps;
format date mmddyy10.;
input empid salary salary2 date mmddyy10.;
month=month(date);
cards;
101 15000 16000 10/11/2006
101 20000 25000 10/12/2006
101 5000 2500 10/12/2006
101 15600 18000 11/09/2006
101 16000 12500 11/12/2006
run;

Then use a proc means to find the summarised values. Note the NWAY option to get only the highest level of combinations and the IDMIN which will take the minimum value of the ID vairable (as opposed to the maximum which is the default). Us the month vairable as the class variable as well as the employee id and drop the month variable along with the automatic variables.

proc means data=emps noprint nway idmin;
class empid month;
id date;
var salary salary2;
output out=tots(drop=_type_ _freq_ month) sum= ;
run;
venkatesh
Calcite | Level 5
Thank You Pznew....

same thing i did by using retain statement in DI studio.,

its Good alternative for Me....both are working fine......

once again Thanks......

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
  • 579 views
  • 0 likes
  • 2 in conversation