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
 

 

Write output is SAS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
phani.mf2011

New User


Joined: 15 Apr 2011
Posts: 17
Location: india

PostPosted: Wed Jul 27, 2011 4:51 pm    Post subject: Write output is SAS
Reply with quote

Hi all I am very new to SAS and trying to learn on my own

Hi below is the code.I am trying to write output .The job is successful with MAXCC=0 but the output file is empty.

Please guide where I went wrong

Code:

//CGNLCOPY EXEC SAS                                             
//CUS      DD   DSN=CGNLST.PK.EZY.SAMP1,DISP=SHR                 
//TES      DD   DSN=CGNLST.PK.SAS.OUT1,DISP=(NEW,CATLG,DELETE), 
//             UNIT=DISK,LRECL=30,AVGREC=K,MGMTCLAS=MONTHLY,     
//             DATACLAS=DATAV,STORCLAS=STANDARD,                 
//             SPACE=(CYL,(10,10),RLSE)                         
//SYSIN    DD  *                                                 
  DATA DATA1;                                                   
  INFILE CUS;                                                   
  INPUT @ 1 EMNAME  $10. @ 11 GEN $1.                           
        @ 12 CITY   $10.;                                       
  RUN;                                                           
  DATA TES;                                                     
    SET DATA1;                                                   
    PUT @23 'SIVA' @;                                           
    OUTPUT;                                                     
Back to top
View user's profile Send private message

PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Jul 27, 2011 4:53 pm    Post subject:
Reply with quote

Try (before the RUN;) :

IF 1 = 1;

or

OUTPUT;
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Wed Jul 27, 2011 5:00 pm    Post subject:
Reply with quote

Hello,
TES DD name is considered as a libname stetement in SAS(in this scenario or filename in some other references)
DATA TES; would create dataset in WORK library which is cleared off when the job completes, so you are getting empty output.
So change
Code:
DATA TES;

to
Code:
DATA TES.TES;


Use PROC PRINT;RUN; statements after datasteps to checkout the data you have read. Provided you have only limited amount of data, cos you dont want to go on printing 1000's of lines on spool.
If you could explain little more on what you are trying to do, then we could help you more on it.

Hope it helps.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Wed Jul 27, 2011 5:13 pm    Post subject:
Reply with quote

I don't know if this is optimal, but I always use the below allocation DCB cards for creating a SAS dataset,

Code:
//          DCB=(BLKSIZE=27648,LRECL=27648,RECFM=FS,DSORG=PS)


If you are intending to write RAW readable output into TES DD name then,
Change,
Code:
DATA TES;                                                     
    SET DATA1;                                                   
    PUT @23 'SIVA' @;                                           
    OUTPUT;   


to
Code:

DATA TES;                                                     
    SET DATA1;         
    FILE TES;                                         
    PUT @23 'SIVA' @;                                           
    OUTPUT;   
RUN;
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Wed Jul 27, 2011 5:35 pm    Post subject:
Reply with quote

Are you attempting to create a SAS data base or are you attempting to write a sequential file? The two are quite different and are used in very different ways.

For a SAS data base, you must use a two-level DATA name to give the DDname and the SAS data base name such as:
Code:
  DATA DATA1;                                                   
  INFILE CUS;                                                   
  INPUT @ 1 EMNAME  $10. @ 11 GEN $1.                           
        @ 12 CITY   $10.;                                       
  RUN;                                                           
  DATA TES.XYZ;                                                     
    SET DATA1;                                                   
    PUT @23 'SIVA' @;                                           
For a sequential file, you must use a FILE statement instead of DATA statement:
Code:
  DATA DATA1;                                                   
  INFILE CUS;                                                   
  INPUT @ 1 EMNAME  $10. @ 11 GEN $1.                           
        @ 12 CITY   $10.;                                       
  RUN;                                                           
  DATA _NULL_;
    SET DATA1;                                                   
    FILE TES ;
    PUT @23 'SIVA' @;                                           
but be aware that this code will create a sequential file with nothing but the characters 'SIVA' starting in column 23 of each record. If you want the input data value in the output file, you must change your PUT statement to write them as well.

If you're building a sequential file with one additional data field, this code would be better:
Code:
  DATA DATA1;                                                   
  INFILE CUS;                                                   
  INPUT @ 1 EMNAME  $10. @ 11 GEN $1.                           
        @ 12 CITY   $10.;                                       
    FILE DATA1;                                                   
    PUT @ 1 EMNAME  $10. @ 11 GEN $1.                           
        @ 12 CITY   $10. @23 'SIVA' @;                                           
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Wed Jul 27, 2011 5:41 pm    Post subject:
Reply with quote

@Robert - Explained like a true expert professor or ex-expert professor (:
Back to top
View user's profile Send private message
phani.mf2011

New User


Joined: 15 Apr 2011
Posts: 17
Location: india

PostPosted: Wed Jul 27, 2011 6:17 pm    Post subject: Reply to: Write output is SAS
Reply with quote

Thanks a lot all

@ Robert---I am able to write data in output file.But it is happening for single records.How to do for all records in input file.Any looping possible
Back to top
View user's profile Send private message
phani.mf2011

New User


Joined: 15 Apr 2011
Posts: 17
Location: india

PostPosted: Wed Jul 27, 2011 6:23 pm    Post subject: Reply to: Write output is SAS
Reply with quote

Thanks a lot all

@ Robert---I am able to write data in output file.But it is happening for single records.How to do for all records in input file.Any looping possible
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Wed Jul 27, 2011 6:24 pm    Post subject:
Reply with quote

The SAS data set does an implied loop -- SAS starts with the first line of the DATA step and goes through each line until the end of it, reading records and writing data as you specified. Unless you change the flow, SAS will then go back and read the next record and proceed through the data step again, and again, until end of data is reached. The last code I posted, with DATA ... INFILE ... INPUT ... FILE .. PUT is the standard way in SAS to completely process the input file and create a new output file.

Be aware that OUTPUT, for example, which you use liberally in your original posted code, can have side effects and is not typically required in a SAS data step since the data will be output by default to the DATA set whenever the end of the data step is reached. Take the last code I posted and try it -- you should get an output file with one record per input file record, exactly the same for the first 22 columns and with SIVA is added in columns 23 to 26.
Back to top
View user's profile Send private message
phani.mf2011

New User


Joined: 15 Apr 2011
Posts: 17
Location: india

PostPosted: Wed Jul 27, 2011 6:33 pm    Post subject: Reply to: Write output is SAS
Reply with quote

please find my code
Code:

//CGNLCOPY EXEC SAS                                             
//CUS      DD   DSN=CGNLST.PK.EZY.SAMP1,DISP=SHR               
//TES      DD   DSN=CGNLST.PK.SAS.OUT1,DISP=(NEW,CATLG,DELETE),
//             UNIT=DISK,LRECL=30,AVGREC=K,MGMTCLAS=MONTHLY,   
//             DATACLAS=DATAV,STORCLAS=STANDARD,               
//             SPACE=(CYL,(10,10),RLSE)                         
//SYSIN    DD  *                                               
  DATA DATA1;                                                   
  INFILE CUS;                                                   
  INPUT @ 1 EMNAME  $10. @ 11 GEN $1.                           
        @ 12 CITY   $10.;                                       
  DATA _NULL_;                                                 
    SET DATA1;                                                 
    FILE TES;                                                   
    PUT @1 EMNAME $10. @11 GEN $1.                             
        @12 CITY $10.                                           
        @23 'SIVA' @;                                           
Back to top
View user's profile Send private message
phani.mf2011

New User


Joined: 15 Apr 2011
Posts: 17
Location: india

PostPosted: Wed Jul 27, 2011 6:48 pm    Post subject: Reply to: Write output is SAS
Reply with quote

Please find my input and output file
input file
Code:
*****************************
 PHANI     1BANGALORE  00000100
 KRISHNA   1HYDERABAD  00000200
 VIJAYA    2TANUKU     00000300
 KAMAL     1BANGALORE  00000400
 RAVIPATI  1VISHAKAPATA00000500
 ****************************


Output file

Code:
***************************
RAVIPATI  1VISHAKAPAT SIVA
***************************
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Jul 27, 2011 6:54 pm    Post subject:
Reply with quote

Change
Code:
   @23 'SIVA' @;
to
Code:
   @23 'SIVA' ;
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Jul 27, 2011 6:56 pm    Post subject: Re: Reply to: Write output is SAS
Reply with quote

Did you try Robert's suggested code?

Is "VISHAKAPATA" losing the final A some sort of typo, or lost in the code?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Wed Jul 27, 2011 6:57 pm    Post subject:
Reply with quote

Well, SAS did EXACTLY what you told it to do -- and I missed it when I posted my code.

The trailing @ on the PUT staement is an error -- take it off. The trailing @ is usually used on an INPUT statement and tells SAS to retain the input record as you're going to read from it again. Since it is on a PUT statement, SAS retains the output record and overlays the data each time, so only the last input record actually gets written to the file. Without the trailing @, the code will write each record.

Sorry about that. icon_redface.gif
Back to top
View user's profile Send private message
phani.mf2011

New User


Joined: 15 Apr 2011
Posts: 17
Location: india

PostPosted: Wed Jul 27, 2011 7:05 pm    Post subject: Reply to: Write output is SAS
Reply with quote

Thanks a lot @expat and @Robert Sample

It work fine.Now I will try practice more
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Jul 27, 2011 9:42 pm    Post subject:
Reply with quote

Robert, I'll PM you my bank account details for your payment icon_lol.gif icon_lol.gif icon_lol.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Wed Jul 27, 2011 10:33 pm    Post subject:
Reply with quote

expat, I don't know if I can afford you! icon_biggrin.gif icon_biggrin.gif
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Jul 27, 2011 10:46 pm    Post subject:
Reply with quote

Exactly the same response as Mrs E icon_lol.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Jul 27, 2011 11:13 pm    Post subject: Reply to: Write output is SAS
Reply with quote

Robert, you could consider what we call a "part exchange" and I believe you would call a "trade in" :-) If it has at least four wheels*, he can "knock it out", I'm sure.

* including steering-wheel
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Thu Jul 28, 2011 12:02 am    Post subject:
Reply with quote

Quote:
If it has at least four wheels*,
I wonder if these four wheels have to be connected .... icon_smile.gif
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 Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm
This topic is locked: you cannot edit posts or make replies. output data in CSV Format janmejay DFSORT/ICETOOL 3 Sat Oct 15, 2016 2:16 pm
No new posts Error IEC161I 052(009,XXXRS00)-084 wh... amitc23 JCL & VSAM 10 Wed Oct 12, 2016 5:00 pm


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