DATA Step, Macro, Functions and more

Writing to a file from sas dataset .. Problem with lrecl= and recfm=?

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 81
Accepted Solution

Writing to a file from sas dataset .. Problem with lrecl= and recfm=?

Hi Dear,

I am writting a SAS dataset to a file. Accourding to my coding , it doesn't write the 2nd and continues records properly in the output file.  when I put recfm=v, it does write properly on file. Can any one tell the reason for this. or Am I doing right if put recfm=v?

  

LIBNAME SWXTEST 'C:\mylib\MAY2011';

FILENAME SWXTEST1 'C:\v_sas_mytest.txt' ;

DATA _NULL_;

file swxtest1 LRECL=4046 RECFM=F ;

set swxtest.v_sas_temp(obs=100);

PUT @    1          APPID                                                   8.   

         @    9          APPTITLE                                             $100.    

         @  109          ORIGINBRANCHID                               $6.    

         @  115          ORIGINOFFICERID                              $1.    

         @  116          PRIBORTYPE                                      $1.    

         @  117          PRIBORID                                            8.    

         @  125          INSTANTRESP                                     $1.    

         @  126          DATEAPPENTRYSTART            datetime20.    

         @  146          PERSONNELID                                    8.    

         @  154          APPLICATIONSOURCE                        $20.    

         @  174          FRSTNAM                                            $15.    

         @  189          LSTNAME                                            $25.    

         @  214          EMPLOYNUM                                       8.    

         @  222          ATTACHREQ                                      $3.    

         @  225          APPLICATIONTYPE                            $4000.    

         @ 4225          SWXVAILABLEREVOLVINGCREDIT    10.2    

         @ 4235          SWXRETURNEDTOBRANCH              $1.    

         @ 4236          SWXTOTALCREDITSTOCONNECTIONS  10.2    

         @ 4246          SWXCONNECTEDBUSINESSCREDIT    10.2   ;

          run;

Thanks very much in advance

Antony


Accepted Solutions
Solution
‎09-21-2011 11:29 PM
PROC Star
Posts: 7,363

Writing to a file from sas dataset .. Problem with lrecl= and recfm=?

If you are expecting 100 records with CR/LFs at the end of each record, remove the recfm= option. I.e., use:

file swxtest1 LRECL=4057;

View solution in original post


All Replies
PROC Star
Posts: 7,363

Writing to a file from sas dataset .. Problem with lrecl= and recfm=?

First a question: what does it do when you specify an lrecl that is as large as the record you are trying to write?

You specify 4046 but then try to write a record that is at least 4255 characters wide.

Frequent Contributor
Frequent Contributor
Posts: 81

Writing to a file from sas dataset .. Problem with lrecl= and recfm=?

Thanks Arthur.

It is my typo. I tried with 4255 with the record lenght as well and put the recfm=f.  but the problem is it is writting the second record very far. It is not write 2nd record at the 4256 column. or row after 4256 column.

thanks

Anton

Solution
‎09-21-2011 11:29 PM
PROC Star
Posts: 7,363

Writing to a file from sas dataset .. Problem with lrecl= and recfm=?

If you are expecting 100 records with CR/LFs at the end of each record, remove the recfm= option. I.e., use:

file swxtest1 LRECL=4057;

Frequent Contributor
Frequent Contributor
Posts: 81

Writing to a file from sas dataset .. Problem with lrecl= and recfm=?

Thanks very much Arthur. It resolved my problem.

Antony

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 154 views
  • 0 likes
  • 2 in conversation