Help using Base SAS procedures

Condensing data sets

Reply
Occasional Contributor
Posts: 5

Condensing data sets

Hi, I have a question on condensing data sets.

For example, how do I change this dataset:

ID Deposit
1 100
1 150
2 50
2 50
2 50
3 75

Into this:
ID Deposit
1 250
2 150
3 75

I am sorting the dataset by ID and I know I might have to use the first. and last. functions, but I'm new to SAS and I can't come up with a solution.

Any help would be appreciated.
Super Contributor
Posts: 359

Re: Condensing data sets

Proc sql;
select id, sum(deposit) deposit from xxx group by id;
quit;
Super Contributor
Posts: 474

Re: Condensing data sets

Or.
[pre]
proc summary data=INDATA nway missing;
class ID; * group var;
var DEPOSIT; * statistic var;
output out=OUTDATA sum= (drop=_TYPE_ _FREQ_);
run;
[/pre]
Cheers from Portugal

Daniel Santos @ www.cgd.pt
Contributor
Posts: 74

Re: Condensing data sets

or:
proc sort data=xxx nodup;
by id;
run;
Contributor
Posts: 74

Re: Condensing data sets

Posted in reply to abdullala
ah, misunderstood the request. ignore please!!!
Ask a Question
Discussion stats
  • 4 replies
  • 192 views
  • 0 likes
  • 4 in conversation