View previous topic :: View next topic
|
Author |
Message |
dharani.nagarajan
New User
Joined: 11 Nov 2010 Posts: 21 Location: India
|
|
|
|
Hi,
Can anyone please help to get a JCL that converts SAS file into a PS flat file.
Thanks,
Dharani |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
|
dharani.nagarajan
New User
Joined: 11 Nov 2010 Posts: 21 Location: India
|
|
|
|
Hi Nic,
What is that SAS program that converts it.. Can you please help me with that
Thanks,
Dharani |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Its "SAS".
Would you show us or answer questions that has been asked by Nic please? |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
"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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dharani.nagarajan
New User
Joined: 11 Nov 2010 Posts: 21 Location: India
|
|
|
|
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 |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1744 Location: Tirupur, India
|
|
|
|
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 |
|
|
dharani.nagarajan
New User
Joined: 11 Nov 2010 Posts: 21 Location: India
|
|
|
|
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 |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1744 Location: Tirupur, India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1744 Location: Tirupur, India
|
|
|
|
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 |
|
|
dharani.nagarajan
New User
Joined: 11 Nov 2010 Posts: 21 Location: India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
I believe the SAS numeric default is double precision floating point, not pure binary. The length = 8 is bytes. |
|
Back to top |
|
|
|