Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output txt file - format for dos/win?

Status
Not open for further replies.

StaticFX

Programmer
Nov 29, 2007
8
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?

Help!
 
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.

Klaz
 
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.


DATA _NULL_;
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 ;
S=INDEX(Line1,'0D'X);
IF S > 0 THEN SUBSTR(Line1,S,1)='';
S=INDEX(Line1,'0A'X);
IF S > 0 THEN SUBSTR(Line1,S,1)='';
A = NC || ' ' || NCVAL;
PUT
@1 A
@5 Line1 $CHAR133.
@138 '0D'x;
RUN ;

 
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.
Code:
data _null_;
  set your_file;
  file your_fileref;
  put ....;
run;
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");
run;
Hope this helps you.
Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top