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
 

 

How to print a variable in SAS program to a dataset.

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

New User


Joined: 22 Jul 2015
Posts: 4
Location: INDIA

PostPosted: Thu Aug 13, 2015 12:24 pm    Post subject: How to print a variable in SAS program to a dataset.
Reply with quote

Hi Everyone,

SAS code :

Code:
DATA STAT;                                     
INFILE INDD;                                   
                                               
   INPUT
                                     
         @001 CHARGE    PD8.7;                 
                                               
                                               
PROC MEANS DATA=STAT NOPRINT;                 
VAR CHARGE;                                   
OUTPUT OUT=REPORT                             
       SUM(CHARGE)=CYCLE26                     
                 N=RECS;                       
                 RUN;                         


I want the sum of charge , that is 'CYCLE26' value alone to be printed in a dataset from position 01 to 20.

Is it possible to print that value in a dataset? If so please explain me how.

thanks in advance.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


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

PostPosted: Thu Aug 13, 2015 6:09 pm    Post subject:
Reply with quote

After your RUN statement:
Code:
DATA _NULL_;
     SET REPORT;
     FILE <ddname> ;
     PUT @11 CYCLE26 10. ;
     RUN;
You must specify the output DD name and put that DD name in the FILE statement. Also, a SAS numeric variable on z/OS is no more than 8 bytes long, which allows at most 16 digits. So at least 4 of the bytes between 1 and 20 will be blank (or zero); I assumed a 10-digit number would be adequate; if not, you can adjust the starting position and length of CYCLE26 yourself.

You did not specify -- you ARE running your SAS on a z/OS machine, right?
Back to top
View user's profile Send private message
LOKESH DAIVAM

New User


Joined: 22 Jul 2015
Posts: 4
Location: INDIA

PostPosted: Fri Aug 14, 2015 11:46 am    Post subject:
Reply with quote

Hi Robert,

Thank you so much, this helped me alot.

Sorry i forgot to mention that am running my sas in AS on a z/OS machine.

I want to print the cycle26 value like this : $400.00000

Am trying with Format,but its showing below erro.

'Variable CYCLE26 has already been defined as numeric.'

Thanks in advance.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri Aug 14, 2015 6:02 pm    Post subject:
Reply with quote

You set the format on the PUT statement:
Code:
PUT @11 CYCLE26 $10.5;
Back to top
View user's profile Send private message
LOKESH DAIVAM

New User


Joined: 22 Jul 2015
Posts: 4
Location: INDIA

PostPosted: Mon Aug 17, 2015 10:15 am    Post subject:
Reply with quote

Hi Robert,

I tried the same but am getting the same error.

Code:
13       !                                                                     
14         DATA _NULL_;                                                         
15              SET REPORT;                                                     
16              FILE OUTDD ;                                                   
17              PUT @01 'CYCLE 26: '                                           
18              PUT @11 CYCLE26 $10.5;                                         
                                _____                                           
                                230                                             
WARNING: Variable CYCLE26 has already been defined as numeric.


Thanks in advance.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Aug 17, 2015 11:24 am    Post subject: Reply to: How to print a variable in SAS program to a dataset.
Reply with quote

So, do you define that item somewhere else? Is there a manual which explains the messages? How have you attempted to fix it?
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Aug 17, 2015 11:51 am    Post subject:
Reply with quote

Hello,

Change this line
Code:
PUT @11 CYCLE26 $10.5; 

to
Code:
PUT @11 CYCLE26 Dollar10.5;
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 IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts A sample of exit program for exit XMN... lind sh CICS 2 Mon Oct 03, 2016 5:07 pm
No new posts Need points to tune IMS Checkpoint Pr... satish.ms10 IMS DB/DC 2 Fri Sep 30, 2016 4:12 pm


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