01-15-2018 11:44 AM - edited 01-15-2018 11:47 AM
Interesting idea to sum up ID's.
If you know about SQL, you can use Proc SQL to solve this.
There are for sure other ways using DATA Step programming or using a Proc such as MEANS.
data have; infile cards; input id; cards; 1 2 3 ; proc sql; select id , (select sum(id) from have) as id_1 from have ; quit;
For next time: please provide a better subject line for the post, so that we have more information already in the title.
Find More information here
01-15-2018 12:02 PM
Here is one proc+datastep method:
data have; input id; datalines; 1 2 3 ; proc summary data=have; var id; output out=sum (drop=_:) sum=id_1; run; data want; set have; if _n_ eq 1 then set sum; run;
Art, CEO, AnalystFinder.com
01-15-2018 06:48 PM
And here's a single data step solution. It's still two passes through the data, but it's a single step.
data want; set have (in=firstpass) have (in=secondpass); if firstpass then sumid+id; if secondpass; run;