FW: Creating a file IF....

FW: Creating a file IF....

Post by Kerrison, Jam » Thu, 07 Sep 2000 05:03:37



Thanks Ian,

FYI for anyone who clipped Howard's code, and is in V8.

"Howard's solution works in 6.12, but V8 has tightened up the code so that
one should not use an existing fileref with the FILEVAR option.  See

SN-001168
Do not use existing fileref with FILEVAR= on INFILE "

-----Original Message-----

Sent: Tuesday, September 05, 2000 3:33 PM
To: 'Kerrison, James'
Subject: RE: Creating a file IF....

James,

FILE is both executable and compile time directive.  As a compile time
directive a buffer is set up and the old file wiped out (unconditionaly when
the code is read).  As an executable the buffer pointer is changed when the
IF statement is true.  However, for an empty dataset, execution stops
on the SET statement.  Howard's solution works in 6.12, but V8 has tightened
up the code so that
one should not use an existing fileref with the FILEVAR option.  See

   SN-001168
Do not use existing fileref with FILEVAR= on INFILE


-----Original Message-----

Sent: Monday, August 28, 2000 11:31 AM

Subject: Creating a file IF....

This seems like a simple enough step, but I can't get it right. I am trying
to create a file IF there is data in a dataset.

My code looks something like this:

data _null_ ;
  set dataset;

if _n_ = 1 then do ;
file "filexxx.txt";


end ;


run ;

I am assuming that if the dataset is null that the if statement will
evaluate to 0, and nothing will happen. However the file is still being
created even though there is no data in the dataset being set! Any ideas or
pointers would be appreciated.

TIA,

Foster Kerrison

 
 
 

FW: Creating a file IF....

Post by Paul Dorfm » Thu, 07 Sep 2000 05:41:15


Foster,

Ian is of course right. However, Howard's solution does not need an existing
fileref (I think I mentioned it in my 'ditto' reply to Howard's post, but am
not quite sure). In this variant,

data _null_;
   retain fname "c:\sastest.txt";
   set dataset;
   file smth filevar=fname;


run;

SMTH is merely a dummy name, not associated with any already assigned
fileref. It *does* work in 8.1. (Actually, despite the tech note, Howard's
variant where the fileref had already been assigned, worked too, but since
the tech note raises a flag, I would comply.)

Kind regards,
===================
Paul M. Dorfman
Jacksonville, Fl
===================




>Subject: FW: Creating a file IF....
>Date: Tue, 5 Sep 2000 16:03:37 -0400

>Thanks Ian,

>FYI for anyone who clipped Howard's code, and is in V8.

>"Howard's solution works in 6.12, but V8 has tightened up the code so that
>one should not use an existing fileref with the FILEVAR option.  See

>SN-001168
>Do not use existing fileref with FILEVAR= on INFILE "

>-----Original Message-----

>Sent: Tuesday, September 05, 2000 3:33 PM
>To: 'Kerrison, James'
>Subject: RE: Creating a file IF....

>James,

>FILE is both executable and compile time directive.  As a compile time
>directive a buffer is set up and the old file wiped out (unconditionaly
>when
>the code is read).  As an executable the buffer pointer is changed when the
>IF statement is true.  However, for an empty dataset, execution stops
>on the SET statement.  Howard's solution works in 6.12, but V8 has
>tightened
>up the code so that
>one should not use an existing fileref with the FILEVAR option.  See

>    SN-001168
>Do not use existing fileref with FILEVAR= on INFILE


>-----Original Message-----

>Sent: Monday, August 28, 2000 11:31 AM

>Subject: Creating a file IF....

>This seems like a simple enough step, but I can't get it right. I am trying
>to create a file IF there is data in a dataset.

>My code looks something like this:

>data _null_ ;
>   set dataset;

>if _n_ = 1 then do ;
>file "filexxx.txt";


>end ;


>run ;

>I am assuming that if the dataset is null that the if statement will
>evaluate to 0, and nothing will happen. However the file is still being
>created even though there is no data in the dataset being set! Any ideas or
>pointers would be appreciated.

>TIA,

>Foster Kerrison

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

 
 
 

1. FW: dynamically create a folder and a file

Are you talking about Excel creating files there or
having SAS create Excel files there or ???

If SAS, which method?    Export  or using DDE
within the datastep or ???

PS:  if you would ever have spaces in the pathname
or the filenames most any one of us here on sas-l
can give you an adjusted syntax for handling the
quoting on that.

2. royalblue ChangeManager

3. Booting ifs-file by lilo.

4. 10BaseT on Cat3 Token-Ring?

5. Questions about IFS Manager and hooking file systems

6. MCSD Exam for Excel95

7. How to create single compressed file with .dr_ extension from same file in a .cab file

8. FS: RAM - 4 4x9x70's

9. Creating links in PDF files created with Adobe Illustrator...

10. Sorting files by date created and creating an HTML list?

11. Create Flight Option - FW Win '95

12. FW: creating HFS