Page 1 of 2

how to compare 3 variables

PostPosted: Fri Jun 29, 2012 11:15 pm
by rick5952
I have a req. to compare three variables(dates) and do some processing on the oldest date.

VAR 1       VAR2          VAR3      OCCURRENCE

102011    092011     102011            1
022012    102011     112011            2
               112011     122011            3


It would almost be like a 3 file match?

How would I do this?

Re: how to compare 3 variables

PostPosted: Fri Jun 29, 2012 11:32 pm
by Robert Sample
EVALUATE or IF -- either can do the task. Depending upon the complexity of what you're needing to do in each case, you can code up a flag to let you know which is earliest, or put the code in the IF / EVALUATE directly.

Re: how to compare 3 variables

PostPosted: Fri Jun 29, 2012 11:40 pm
by rick5952
Thanks. Maybe I'm trying to make it too difficult.

Re: how to compare 3 variables

PostPosted: Fri Jun 29, 2012 11:49 pm
by dick scherrer
Hello and welcome to the forum,

Is all of the comparing to be done within the same record?

It would almost be like a 3 file match?
Not really, because in a 3-file match there is the need to keep all 3 files in sync.

Maybe I'm trying to make it too difficult.
Quite possibly . . .

Re: how to compare 3 variables

PostPosted: Sat Jun 30, 2012 12:27 am
by zatlas1
       MOVE 1 TO X
       MOVE VAR1 TO WS-VAR
       IF VAR2 > WS-VAR
          MOVE 2 TO X
          MOVE VAR2 TO WS-VAR
       END-IF
       IF VAR3 > WS-VAR
          MOVE 3 TO X
          MOVE VAR3 TO WS-VAR
       END-IF
      * ETC.

Re: how to compare 3 variables

PostPosted: Sat Jun 30, 2012 6:37 am
by steve-myers
I'm not a Cobol person, but I do have a couple of generic comments.
  • The dates you show are not Y2K compliant. This will cause endless problems especially if you have dates from the 1900s.
  • While the chances this program and the underlying dates will still be in use in 2100 are essentially 0, it's hard to believe that after the Y2K trauma, the policies that led to the Y2K trauma are still being used. Let me be the first to predict the Y21K trauma will be worse than the Y2K trauma if this thoughtless cr** persists.
  • The year portion of the date should be compared before the mmdd portion of the date.

Re: how to compare 3 variables

PostPosted: Tue Jul 03, 2012 2:48 am
by rick5952
thanks for your concern but the dates are a non issue

Re: how to compare 3 variables

PostPosted: Tue Jul 03, 2012 5:00 am
by steve-myers
rick5952 wrote:thanks for your concern but the dates are a non issue
Please explain.
  • The alleged data clearly appears to be dates.
  • There are correct and incorrect ways to store dates in storage to facilitate date comparison.
  • There are correct and incorrect ways to compare dates based on the way the date is stored in storage.
  • The way a date appears in output is not the issue here, but that can be confusing, too.

Re: how to compare 3 variables

PostPosted: Tue Jul 03, 2012 8:43 am
by dick scherrer
Hello,

thanks for your concern but the dates are a non issue
How can this be as the Only data you posted is dates. . . :?

As posted, the dates CanNot be compared as dates. . .

Possibly your question had nothing to do with dates in which case you should have posted data reflecting what you really wanted to learn how to accomplish.

Playing guessing games just wastes everyone's time. . . Yours and ours.

Re: how to compare 3 variables

PostPosted: Wed Jul 04, 2012 1:58 am
by rick5952
thanks for wasting mine