I wanted to convert one of my Proc SQL/SAS code in Rev R/Microsoft-r
here is my sample code
proc sql;
create table GENDER_YEAR as
select YEAR,GENDER,count(distinct CARD_NO) as CM_COUNT,sum(SPEND) as TOTAL_SPEND, sum(case when SPEND GT 0 then 1 else 0 end) as NO_OF_TRANS
from ABC group by YEAR,GENDER;
quit;
I'm trying below code in Rev R
library("RevoPemaR")
byGroupPemaObj <- PemaByGroup()
GENDER_cv_grouped <- pemaCompute(pemaObj = byGroupPemaObj, data = Merchant_Trans,groupByVar = "GENDER",computeVars = c("LOCAL_SPEND"),fnList = list(sum = list(FUN = sum, x = NULL)))
it Calculate only on thing at a time, but i need Distinct Count of CARD_NO, SUM of SPEND, and No of no zero Rows for Spend as Trans for each segment of YEAR & Gender.
Output Should look like below
YEAR  GENDER CM_COUNT TOTAL_SPEND NO_OF_TRANS
YEAR1 M      23        120        119
YEAR1 F      21        110        110
YEAR2 M      20        121        121
YEAR2 F      35        111        109
Looking forward help on this.
 
     
    