Date: Sun, 18 Aug 1996 16:53:58 +0100
Reply-To: Howard Lethbridge <lethcon@DIRCON.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Howard Lethbridge <lethcon@DIRCON.CO.UK>
Subject: Re: Multiple file statements in one data step
>Date: Sat, 17 Aug 1996 22:51:27 +0100
>To: sas-l
>From: Howard Lethbridge <lethcon@dircon.co.uk>
>Subject: Re: Multiple file statements in one data step
>
>At 21:00 15/08/96 -0500, you wrote:
>>The following code is intended to print to (and overwrite) a file already on
>>the disk. The subsequent conditional statements are to print certain data to
>>a completely different file and to append certain data to the original print
>>file ... all in one data step. The problem is that apparently the MOD option
>>on the second FILE PRINT statement becomes operative throughout the data step.
>>So instead of overwriting the file to begin with, it appends everything to the
>>file on the disk.
>>
>>If the statements are in separate data steps, it works.
>>
>>Is there a reason for this or is it a bug?
>>
>>
>>data; file 'test.tst' print notitles;
>>put 'xyz';
>>do j=1 to 2;
>> if j=1 then do;
>> file 'test2.tst';
>> put 'xyz2';
>> end;
>> else do;
>> file 'test.tst' print notitles mod;
>> put 'xyz3';
>> end;
>>end;
>>run;
>>
>>--Hays McLean
>>
>
If I've understood you correctly, then if you just remove the MOD option, it
should work. Within the same data step, subsequent writes to an external
file will always append to the end. The MOD option simply says where to
start from, i.e. at the end (MOD) or from the beginning (without MOD).
_______________________________________________________________
Howard J Lethbridge
+44 (0)181-907 8655
lethcon@dircon.co.uk
|