Dear All
My data is as follows. On July 3 2020 VariableC should restatrt the Aggregation
DATE Time VariableA VariableB Var_AGG
01JAN2020 9:30:05 B 100 100
01JAN2020 9:30:08 S 25 75
02JAN2020 10:45:45 S 25 50
02JAN2020 11:26:13 B 35 85
03JUL2020 13:15:58 B 205 205
03JUL2020 13:45:08 S 45 160
On July 3 2020 VariableC should restatrt the Aggregation. And the needed data is as follows
DATE Time VariableA VariableB Var_AGG
01JAN2020 9:30:05 B 100 100
01JAN2020 9:30:08 S 25 75
02JAN2020 10:45:45 S 25 50
02JAN2020 11:26:13 B 35 85
03JUL2020 13:15:58 B 205 205
03JUL2020 13:45:08 S 45 160
Can someone please help. Thank you in advance.
Randy
What is the rule that determines when aggregation should restart?
Art, CEO, AnalystFinder.com
On the date; July 3, 2020 (03JUL2020)
Seems too determined to be realistic, but the following would meet your condition:
data want;
set have;
by date;
if _n_ eq 1 or (date eq '03JUL2020'd and lag(date) ne '03JUL2020'd) then Var_AGG=0;
if VariableA='B' then Var_AGG+VariableB;
else Var_AGG+-1*VariableB;
run;
Art, CEO, AnalystFinder.com
Yes that is true. The reason is a quarters worth of missing data and the data is again available after a quarter.
I see no VariableC in your "needed" data. What should it aggregate? Sums, counts?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.