BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JackZhang
Calcite | Level 5

I stuck in a loop question.

For example

I have

SCHED_VOL          LEAD_BATCH    LAG_BATCH   IND

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

SCHED_VOL          LEAD_BATCH    LAG_BATCH   IND         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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Data want;

     set have;

     ind = (LEAD_BATCH ne LAG_BATCH);

     if ind then Cum_VOL=SCHED_VOL;

     else Cum_Col + SCHED_VOL;

run;

might work

View solution in original post

2 REPLIES 2
ballardw
Super User

Data want;

     set have;

     ind = (LEAD_BATCH ne LAG_BATCH);

     if ind then Cum_VOL=SCHED_VOL;

     else Cum_Col + SCHED_VOL;

run;

might work

JackZhang
Calcite | Level 5

Perfect, Ballardw. Thank you very much

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 759 views
  • 0 likes
  • 2 in conversation