Hi. I'm wondering if it's possible to sum all instances of the Total column with Score_Impacting = 'N' (see attached)? Is there a built-in for this or how could I accomplish this?
I'm thinking maybe something like this???
if rule_nm = 'MATCHING + NO SCORE IMPACTING' then do;
total = sum(total (where score_impacting='N'));
end;
OK, how about this way then:
proc means data=FinalData sum;
where rule_nm = 'MATCHING + NO SCORE IMPACTING' and score_impacting='N';
var total _: null;
output out=cal_sums (drop=_type_ _freq_) sum=;
run;
No, it depends on how you want the final results and if you're in a reporting procedure or data step.
Proc means is one way, proc sql is another, and there are others. But we need more information.
As long as you don't need code, feel free to include pictures.
Going back to your original code, would it not be as simple as this:
if rule_nm = 'MATCHING + NO SCORE IMPACTING' and score_impacting='N' then grand_total + total;
Seems I'm hung up here. The reference to sum(_:) is my attempt to apply the sum() function to all my variables beginning with _. For instance I may have variables:
_04_11_2016
_3_26_2016
etc....
The problem is these variables are the product of a previous Proc Transpose and they will not be the same with each run of the program. Is there a way to work around my issue?
108 proc sql;
109 CREATE TABLE cal_sums AS
110 select sum(total) as total, sum(_:), sum(null)
-
22
200
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, ), *, **, +, ',', -, '.', /, <, <=, <>, =, >, >=, ?,
AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^,
^=, |, ||, ~, ~=.
ERROR 200-322: The symbol is not recognized and will be ignored.
111 from FinalData
112 where rule_nm = 'MATCHING + NO SCORE IMPACTING'
113 and score_impacting='N';
114 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
OK, how about this way then:
proc means data=FinalData sum;
where rule_nm = 'MATCHING + NO SCORE IMPACTING' and score_impacting='N';
var total _: null;
output out=cal_sums (drop=_type_ _freq_) sum=;
run;
Wow...that looks promising, but it seems to have dropped the Rule_nm and Rule_order variables. Is there a way to carry these thru to Cal_Sums dataset?
Do you want separate totals for each Rule_order?
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.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.