IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert SAS file to aflat file


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dharani.nagarajan

New User


Joined: 11 Nov 2010
Posts: 21
Location: India

PostPosted: Mon Sep 22, 2014 10:06 pm
Reply with quote

Hi,

Can anyone please help to get a JCL that converts SAS file into a PS flat file.

Thanks,
Dharani
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Sep 23, 2014 1:18 am
Reply with quote

JCL won't do that - it only tells the OS what programs you want to run and the resources required.

What is a SAS file? Is it not already a PS file? If not, what format is it? If SAS does have its own formats of datasets (not files) then use a SAS program to convert it.
Back to top
View user's profile Send private message
dharani.nagarajan

New User


Joined: 11 Nov 2010
Posts: 21
Location: India

PostPosted: Tue Sep 23, 2014 2:17 am
Reply with quote

Hi Nic,

What is that SAS program that converts it.. Can you please help me with that

Thanks,
Dharani
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Tue Sep 23, 2014 3:02 am
Reply with quote

Its "SAS".
Would you show us or answer questions that has been asked by Nic please?
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Tue Sep 23, 2014 3:28 am
Reply with quote

"SAS" is a large program. There are mainframe versions as well as other versions for a number of other platforms.

In the mainframe version of "SAS," the program maintains "files" in a container data set somewhat like members of a mainframe partitioned data set. The internal format of the container data set, as well as the "files," is proprietary to the SAS Institute.

It has been more than 20 years since I last worked with "SAS." If I remember correctly, the "SAS" program provides a method "PROC PRINT?" to list the contents of a "file" in a SAS container data set. Consult "SAS" documentation for more details.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Tue Sep 23, 2014 8:03 am
Reply with quote

If you are talking about converting a SAS data base into a flat file, this MUST be done through SAS. SAS two-level names work on sequential data sets, but they are specially formatted so that SAS can process them more efficiently.

Furthermore, the simplest way to do this is probably not what you want:
Code:
DATA _NULL_ ;
SET A.SASDB;
FILE B ;
PUT _ALL_;
will take SAS data base SASDB associated with DDNAME A and dump it to a sequential data set with DDNAME B. Will this data be usable by COBOL or any other language? No -- SAS dumped the data with VARNAME=value for every variable in every record of the data base (not to mention the missing values issue where SAS represents missing values with a period or space).

Perhaps you could provide some more detailed information about what you are trying to do and we can provide better answers. However, your best bet for getting good help will be your own site support group.
Back to top
View user's profile Send private message
dharani.nagarajan

New User


Joined: 11 Nov 2010
Posts: 21
Location: India

PostPosted: Thu Sep 25, 2014 9:50 pm
Reply with quote

Thank you so much Robert.

I have a file with
Record format as FS and Record length : 27648

By using the below step I got the contents of this file

//STEP001 EXEC SAS,WORK='1500,1500',
// OPTIONS='MACRO,DQUOTE,COMPRESS=NO'
//*
//ALLOC DD DSN=TEST.INPUT.SAS1,
// DISP=SHR
//SASLOG DD SYSOUT=*
//SASOUT DD SYSOUT=*
//SYSIN DD *
OPTIONS NOCENTER OBS=MAX;
PROC CONTENTS DATA = ALLOC._ALL_;RUN;
//*


Using this content as the file structure I have to write the records from this input file to a PS file with RECFM FB and Record length 226.

Length 226 I got from the content structure.

Thanks,
Dharani
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Thu Sep 25, 2014 10:39 pm
Reply with quote

Hello,
You are on the right path in starting with CONTENTS procedure.
How did you determine this?
Quote:
Length 226 I got from the content structure.


You need to follw Robert's post earlier after doing the CONTENTS.

Code:
libname A 'TEST.INPUT.SAS1' disp=shr;
filename B 'YOUR.OUTPUT.PS.FILE' disp=old;
DATA _NULL_ ;
SET A.SASDB;
FILE B ;
PUT _ALL_;
run;
Back to top
View user's profile Send private message
dharani.nagarajan

New User


Joined: 11 Nov 2010
Posts: 21
Location: India

PostPosted: Tue Sep 30, 2014 11:28 pm
Reply with quote

Thank you Vasanth..

What does 'NUM' specifies in the content..

Field1 Num 8

Is that a Zone decimal or a Packed decimal

Can you please let me know.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Wed Oct 01, 2014 1:18 am
Reply with quote

Hello,
SAS stores all data with only two variable types, character and numeric.
Note: NUM 8 does not mean that it is a number which can have only 8 digits.

This one is just a numeric value. It can contain any value in it like
3000000000345, or 344556.4567234. or -34234653454576
All of them represented as NUM.

Even if you read a PS file into SAS, which has binary data or packed data as input, SAS will still store it as NUM "format" by default.

It matters only when you print the value in the dataset.

You could start with "The little SAS book" to get hold of the SAS concepts, its a well written book. I cannot explain it in COBOL analogy since I have not worked in COBOL.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Oct 01, 2014 4:03 am
Reply with quote

IIRC (and since it has been a while since I had to look it up, I could be wrong), SAS stores numeric values as binary (COMP-5 in COBOL) internally no matter what they started out as.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Wed Oct 01, 2014 8:07 pm
Reply with quote

Robert,
You are correct, the FORMAT of the data is num, however as you said the data is actually in binary.

I wonder why would the TS want to know how the data is actually stored?

Dharani, are you trying to write a COBOL program to read a SAS file and write to a PS file?
If that is the idea, then it may not work.
Back to top
View user's profile Send private message
dharani.nagarajan

New User


Joined: 11 Nov 2010
Posts: 21
Location: India

PostPosted: Thu Oct 02, 2014 1:11 am
Reply with quote

Thank you Robert and Vasanth.

I'm trying to create a PS file from the SAS file. I want to use the PS file in a COBOL program.

So the PS file I write should be in COBOL acceptable format.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Oct 02, 2014 1:31 am
Reply with quote

Do you know what is in the SAS file? If not, do a PROC CONTENTS on it to find out. Then you do something like this in SAS:
Code:
DATA _NULL_ ;
SET A.SASDB ;
FILE B ;
PUT @001 VAR1 <name then format for the first variable>
    @??? VAR2 <name then format for the second variable>
etc
VAR1 and VAR2 are just examples -- use the actual variable names from the SAS PROC CONTENTS. And you don't have to keep the variables in the SAS file order; you can rearrange them as needed for your COBOL program.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Tue Oct 14, 2014 8:35 am
Reply with quote

I believe the SAS numeric default is double precision floating point, not pure binary. The length = 8 is bytes.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top