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

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


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Aug 13, 2015 6:09 pm
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 14, 2015 6:02 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Aug 17, 2015 11:24 am
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: 1742
Location: Tirupur, India

PostPosted: Mon Aug 17, 2015 11:51 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Allocated cylinders of a dataset DB2 12
Search our Forums:

Back to Top