turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- ODS and Base Reporting
- /
- need help converting COBOL logic statements to SAS...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-16-2012 02:02 PM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to chandler

05-16-2012 07:14 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Cynthia_sas

05-17-2012 11:02 AM

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).

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to chandler

05-17-2012 12:50 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Cynthia_sas

05-17-2012 01:28 PM

Than you, Cynthia, for your quick response. I will checkout these links.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to chandler

06-15-2016 02:00 AM

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!