BookmarkSubscribeRSS Feed
gskn4u
Obsidian | Level 7

Hi All,

I am having issue when writing the data into mainframe file.

when I print DATA01, I see no issues. but when I write to output file I get completely different data (not as expected).

The record length is approximately 1200.

can someone please help me.

Best Regards,

DATA _NULL_;                                                      
  FILE OUTFL1 NOPRINT NOTITLES       ;                        
  FORMAT VAR1   VAR2 VAR3 VAR4 VAR5 VAR6       $050     
     VAR7   VAR8 VAR9 VAR10 VAR11 VAR12    $100     
     ;                                                        
  SET TOLIST ;                                                    
  IF _N_ = 1 THEN                                                 

  PUT @001 'VAR1,VAR2,VAR3,VAR4,VAR5,VAR6,VAR7,VAR8,VAR9,VAR10,VAR11,' 

  @058 'VAR12,' ;                                             
  PUT @001 VAR1        $050. '","'                            
  @053 VAR2        $050. '","'  

.

.

.

.

.                         
                                                                  

  ;   

3 REPLIES 3
gskn4u
Obsidian | Level 7

Hi All,

I resolved the issue by using DLM = ',' DSD option in FILE Statement

But I could not find why PUT was writing incorrect/wired values to output.

DATA _NULL_;                                                      
  FILE OUTFL1 NOPRINT NOTITLES  DLM = ',' DSD     ;                        
  FORMAT VAR1   VAR2VAR3VAR4 VAR5 VAR6       $050     
     VAR7   VAR8VAR9VAR10 VAR11 VAR12    $100     
     ;                                                        
  SET TOLIST ;                                                    
  IF _N_ = 1 THEN                                                 

  PUT @001 VAR1 VAR2 VAR3 VAR4 VAR5 VAR6 VAR7 VAR8 VAR9 VAR10 VAR11 ;

Tom
Super User Tom
Super User

Why do you have a FORMAT Statement in this DATA _NULL_ step that is just assigning generic $ formats to variables? 

Perhaps you meant to use a LENGTH statement?  But even then for this data step since you are not modifying the data why would you need to change the length from what it has on input data set.

Doc_Duke
Rhodochrosite | Level 12

Hi,

Please just post a question once to the forums.

The first thing that I noticed is that your format statement is incorrectly formatted.  The FORMATs require a period (".") at the end (e.g. "$050.").  You have it correct in you PUT statement.

I am concerned that putting the NOPRINT and NOTITLES options on a non-print device may confuse the system.  Try removing them.

Can you provide an example of the input data and the correct and incorrect output.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 812 views
  • 0 likes
  • 3 in conversation