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?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.