## Simple Loops

Solved
Occasional Contributor
Posts: 9

# Simple Loops

I stuck in a loop question.

For example

I have

10000.00                 OSH                   MSB                1

10000.00                 MSB                   OSH                 1

20000.00                 OSH                   OSH                 0

20000.00                 OSH                   MSB                 0

20000.00                 MSB                   OSH                 1

15000.00                 OSH                   OSH                 0

16000.00                 OSH                   MSB                  1

if lead-bath nq lagbatch, i indicate asa 1, otherwise 0.

Now I need run the loops, when it is 0, add cumulative vol,otherwise = sched_VOl

something like this for Cum_VOL

10000.00                 OSH                   MSB                1             10000

10000.00                 MSB                   OSH                 1             10000

20000.00                 OSH                   OSH                 0             30000

20000.00                 OSH                   MSB                 0             50000

20000.00                 MSB                   OSH                 1             20000

15000.00                 OSH                   OSH                 0             35000

16000.00                 OSH                   MSB                  1            16000

I think it is not difficult, but I cannot get exact answer.

Thank you very much

Accepted Solutions
Solution
‎04-20-2015 01:51 PM
Super User
Posts: 13,563

## Re: Simple Loops

Data want;

set have;

if ind then Cum_VOL=SCHED_VOL;

else Cum_Col + SCHED_VOL;

run;

might work

All Replies
Solution
‎04-20-2015 01:51 PM
Super User
Posts: 13,563

## Re: Simple Loops

Data want;

set have;

if ind then Cum_VOL=SCHED_VOL;

else Cum_Col + SCHED_VOL;

run;

might work

Occasional Contributor
Posts: 9

## Re: Simple Loops

Perfect, Ballardw. Thank you very much

🔒 This topic is solved and locked.