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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 986 views
  • 0 likes
  • 3 in conversation