Here is my problem. I have a dataset and it has more than one bucket. Each row can have 5 buckets and it can essentially have infinite amount of rows.
Here is an example of the code I'm trying to write:
NetCount = Maxcount-extra;
if ( NetCount >0 ) and (NetCount = count) then do;
Extra = Extra+1;
As you can see I'm trying to loop through each row and create buckets 1-5, buckets 6-10. I also have written code to find the Maximum amount of rows needed which is represented by Maxcount (Maxium of count). SAS won't let me create these new variables this way.
It seem that you have borrowed some syntax from an other programming language (in your calculations for example). You said that you calculated Maxcount, how? If you pre-calculated, is it in every row of work1 table? A more convenient way is to store it in a macro variable.
Please attach some sample input data, and desired output, and maybe describe what a bucket is in this example.
To avoid some heavy data step programming, I suggest that you first transpose the data downwards, so that you will have one roe per policy and bucket. Then you can us PROC TRANSPOSE to transpose your data upwards again. I think this is quite nice since you don't have to keep track of "anything", like maxcout etc:
array buckets bucket1-bucket5;
do i = 1 to 5;
if buckets ne 0 then do;
bucket = buckets;
keep policy bucket;
proc transpose data=transpose1 out=transpose2(drop=_name_) prefix=bucket;