Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Convert SAS file to aflat file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
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    Post subject: Convert SAS file to aflat file
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: 1717
Location: UK

PostPosted: Tue Sep 23, 2014 1:18 am    Post subject: Reply to: Convert SAS file to aflat file
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    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Tue Sep 23, 2014 3:02 am    Post subject:
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 User


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

PostPosted: Tue Sep 23, 2014 3:28 am    Post subject:
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: 7914
Location: Bellevue, IA

PostPosted: Tue Sep 23, 2014 8:03 am    Post subject:
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    Post subject:
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: 1445
Location: Azeroth

PostPosted: Thu Sep 25, 2014 10:39 pm    Post subject:
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    Post subject:
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: 1445
Location: Azeroth

PostPosted: Wed Oct 01, 2014 1:18 am    Post subject:
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: 7914
Location: Bellevue, IA

PostPosted: Wed Oct 01, 2014 4:03 am    Post subject:
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: 1445
Location: Azeroth

PostPosted: Wed Oct 01, 2014 8:07 pm    Post subject:
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    Post subject:
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: 7914
Location: Bellevue, IA

PostPosted: Thu Oct 02, 2014 1:31 am    Post subject:
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

Active Member


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

PostPosted: Tue Oct 14, 2014 8:35 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us