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: 8578
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: 8578
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: 7310
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: 1693
Location: Tiruppur, 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 Trying to reference a javascript glob... CLIST & REXX 7
No new posts Is it possible to allocate DA dataset... All Other Mainframe Topics 5
No new posts passing stem variable with VPUT/VGET ... CLIST & REXX 6
No new posts Map VSAM Dataset to a Table/Tablespace DB2 2
No new posts DECIMAL HOST VARIABLE OR PARAMETER 14... DB2 7
Search our Forums:

Back to Top