BookmarkSubscribeRSS Feed
chandler
Fluorite | Level 6

I have a text file from a programmer with the COBOL logic statements to perform some ratio calculations.   I need to build a program in SAS to do the same thing.  While I understand some of the COBOL logic, I need some examples to show me the equivalent statment in SAS code.  I would appreciate any link you can give me to documentation or a tutorial.

5 REPLIES 5
Cynthia_sas
SAS Super FREQ

Hi:

Usually when folks need help with COBOL and SAS, they want to know how to convert a COBOL file definition for an input file into a SAS INPUT statement. If you search the SAS web site for COB2SAS, you will find a way to convert a COBOL copybook file definition into a SAS INPUT statement.

  Otherwise, I'm not sure what you mean by COBOL "logic" -- when I used COBOL, we wrote our programs in paragraphs such that each paragraph performed a separate function -- such as read a record, do some calculations, look something up, build an output record, write the output record to a file or build a report line and move the report line to a report file. If that is the type of help you are seeking, then I'd suggest you read papers and tutorials on using the SAS DATA step program to perform processing.

cynthia

chandler
Fluorite | Level 6

Thanks, Cynthia.  I guess I mean the procedure division.  Here is a sample of the code.  I need to do a SAS equivalent to this EVALUATE procedure and COMPUTE procedures below:

           IF WS-RESPONSE-CODE = DFHRESP(LENGERR)

              MOVE ZEROES TO WS-RESPONSE-CODE

           END-IF

           EVALUATE WS-RESPONSE-CODE

                    WHEN DFHRESP(NOTFND)

                        INITIALIZE LO-WORK-GUARANTOR (1)

                        INITIALIZE LO-WORK-GUARANTOR (2)

                        INITIALIZE LO-WORK-GUARANTOR (3)

                        INITIALIZE LO-WORK-GUARANTOR (4)

                        INITIALIZE LO-WORK-GUARANTOR (5)

                        INITIALIZE LO-WORK-GUARANTOR (6)

                    WHEN DFHRESP(NORMAL)

                        MOVE WS-LOSBMISC-REC TO WS-LOSBWORK-GAR-REC

                        IF LO-WORK-GUARANTOR-OCCURS = +1

                           INITIALIZE LO-WORK-GUARANTOR (2)

                           INITIALIZE LO-WORK-GUARANTOR (3)

                           INITIALIZE LO-WORK-GUARANTOR (4)

                           INITIALIZE LO-WORK-GUARANTOR (5)

                           INITIALIZE LO-WORK-GUARANTOR (6)

                        END-IF

                        IF LO-WORK-GUARANTOR-OCCURS = +2

                           INITIALIZE LO-WORK-GUARANTOR (3)

                           INITIALIZE LO-WORK-GUARANTOR (4)

                           INITIALIZE LO-WORK-GUARANTOR (5)

                           INITIALIZE LO-WORK-GUARANTOR (6)

                        END-IF

                        IF LO-WORK-GUARANTOR-OCCURS = +3

                           INITIALIZE LO-WORK-GUARANTOR (4)

                           INITIALIZE LO-WORK-GUARANTOR (5)

                           INITIALIZE LO-WORK-GUARANTOR (6)

                        END-IF

                        IF LO-WORK-GUARANTOR-OCCURS = +4

                           INITIALIZE LO-WORK-GUARANTOR (5)

                           INITIALIZE LO-WORK-GUARANTOR (6)

                        END-IF

                        IF LO-WORK-GUARANTOR-OCCURS = +5

                           INITIALIZE LO-WORK-GUARANTOR (6)

                        END-IF

                    WHEN OTHER

                        GO TO U105-EXIT

           END-EVALUATE.

      *

      * BEGIN INTERMEDIATE CALCS FOR GUARANTORS, (JUST LIKE QLOAPP84).

      *

           COMPUTE WS-GAR-CASH1-COL1 ROUNDED =

                                   LO-WORK-GAR-SAL-PER1-AMT (1) +

                                   LO-WORK-GAR-INTDIV-PER1-AMT (1) +

                                   LO-WORK-GAR-SCHED-C-PER1-AMT (1) +

                                   LO-WORK-GAR-CAPGAIN-PER1-AMT (1) +

                                   LO-WORK-GAR-RENTS-PER1-AMT (1) +

                                   LO-WORK-GAR-DEPR-ADJ-PER1-AMT (1) +

                                   LO-WORK-GAR-INT-ADJ-PER1-AMT (1) +

                                   LO-WORK-GAR-OTH-INC-PER1-AMT (1) -

                                   LO-WORK-GAR-INC-TAX-PER1-AMT (1) -

                                   LO-WORK-GAR-LIV-EXP-PER1-AMT (1).

006570*

           COMPUTE WS-GAR-CASH1-COL2 ROUNDED =

                                   LO-WORK-GAR-SAL-PER2-AMT (1) +

                                   LO-WORK-GAR-INTDIV-PER2-AMT (1) +

                                   LO-WORK-GAR-SCHED-C-PER2-AMT (1) +

                                   LO-WORK-GAR-CAPGAIN-PER2-AMT (1) +

                                   LO-WORK-GAR-RENTS-PER2-AMT (1) +

                                   LO-WORK-GAR-DEPR-ADJ-PER2-AMT (1) +

                                   LO-WORK-GAR-INT-ADJ-PER2-AMT (1) +

                                   LO-WORK-GAR-OTH-INC-PER2-AMT (1) -

                                   LO-WORK-GAR-INC-TAX-PER2-AMT (1) -

                                   LO-WORK-GAR-LIV-EXP-PER2-AMT (1).

006570*

           COMPUTE WS-GAR-CASH1-COL3 ROUNDED =

                                   LO-WORK-GAR-SAL-PER3-AMT (1) +

                                   LO-WORK-GAR-INTDIV-PER3-AMT (1) +

                                   LO-WORK-GAR-SCHED-C-PER3-AMT (1) +

                                   LO-WORK-GAR-CAPGAIN-PER3-AMT (1) +

                                   LO-WORK-GAR-RENTS-PER3-AMT (1) +

                                   LO-WORK-GAR-DEPR-ADJ-PER3-AMT (1) +

                                   LO-WORK-GAR-INT-ADJ-PER3-AMT (1) +

                                   LO-WORK-GAR-OTH-INC-PER3-AMT (1) -

                                   LO-WORK-GAR-INC-TAX-PER3-AMT (1) -

                                   LO-WORK-GAR-LIV-EXP-PER3-AMT (1).

Cynthia_sas
SAS Super FREQ

Hi:

  I'm not aware of any COBOL to SAS processing tutorials.Most of the papers deal with converting the COBOL file description to a SAS INPUT statement, as I said, however, this is a general type of overview:

http://www2.sas.com/proceedings/sugi25/25/po/25p211.pdf

  A discussion of SAS DATA step processing, and how to construct assignment statements, IF statements or execute conditional logic or implement arrays would take quite a long time and many, long posts.

   I assume that you know how the COBOL program works, and what the inputs and outputs look like. The key will be to understand how to get the results you want with SAS. Until you understand the DATA step program and SAS programming syntax it will be hard for you to convert your program.

  Here are some useful papers. They don't discuss COBOL at all. They all explain different aspects of how SAS works.

http://www.nesug.org/Proceedings/nesug11/ds/ds04.pdf

http://www2.sas.com/proceedings/sugi29/252-29.pdf

http://www2.sas.com/proceedings/forum2007/273-2007.pdf

http://www2.sas.com/proceedings/sugi29/253-29.pdf

  cynthia

SwatiPanda
Calcite | Level 5

Hello Chandler. I am working on a similar coversion and facing similar issue. How have you worked on the cobol code above ? You inputs can help me as well. Thanks!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

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
  • 5 replies
  • 2457 views
  • 0 likes
  • 3 in conversation