Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Output txt file - format for dos/win?

Output txt file - format for dos/win?

Output txt file - format for dos/win?

Is there a way to make the FILE...PUT method work for dos/windows?

i open the file in notepad and its no good.
tried using FILE NOPRINT but it didnt seem to make any difference?


RE: Output txt file - format for dos/win?

I am not sure of what doesn't work for you. I have been using the File..PUT statements in Windows for years.

Perhaps you can show us the code that you're trying to run.


RE: Output txt file - format for dos/win?

the problem is that we run SAS on a unix box, so the put statement is not win formatted.

i know this probably looks strange to you SAS pros (im only a few years into sas coding - and not an every day thing)

but this JUST about worked... it still has an odd CR here and there but at least notepad opens the resulting file and it looks good.

        SET RAWREC1 ;
        FILE "/home/xxxxxx/check_output/&FILENAME" LS=140 NOPRINT;
        TMP = 'NC(Y/N)' || '0D0A'x || '  NC VALIDATED?' || '0D'x;
        IF _N_ = 1 THEN DO ;
            PUT TMP;
        END ;
        IF S > 0 THEN SUBSTR(Line1,S,1)='';
        IF S > 0 THEN SUBSTR(Line1,S,1)='';
        A = NC || ' ' || NCVAL;
        @1 A
        @5 Line1 $CHAR133.
        @138 '0D'x;


RE: Output txt file - format for dos/win?

I don't think that you should do this in SAS. While the code seems to work there may be something that you miss as the text file changes.

Why not output using the SAS FILE...PUT statements to a UNIX formatted text file and then have SAS call a conversion program (AWK, or on Solaris - unix2dos) on your output.


data _null_;
  set your_file;
  file your_fileref;
  put ....;
data _null_;
  x = pathname(your_fileref);
***  for Solaris ***;
  y = system('unix2dos "'||trim(x)||'" "targetfile.txt"');
*** for reg UNIX ***;
  y = system("awk '"||'sub("$", "\r")'||"' unixfile.txt > winfile.txt");
Hope this helps you.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close