- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 06-14-2020 08:50 AM
(1713 views)
Hello,
I am working on converting some Stata code to SAS and running into trouble with a line including egen = sum(another variable):
bys var1 var2: egen vary= sum(varx)
Do you know how this could be translated into SAS code?
Thanks!
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @n7
Assuming that 'varx' as no missing value and that 'vary' corresponds to the sum of 'varx' value in each subgroup made of a unique combination of 'var1' and 'var2', you can try this:
proc sql;
create table want as
select *, sum(varx) as vary
from have
group by var1, var2;
quit;
Best,
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would think it is
proc sql;
select var1, var2, sum(varx) as vary
from have
group by var1, var2;
quit;
see if it gives the same result.