Date: Wed, 2 Jul 2003 10:50:28 +0200
Reply-To: Ace <b.rogers@VIRGIN.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ace <b.rogers@VIRGIN.NET>
Subject: Re: fopen() and infile correspondence
Content-Type: text/plain; charset=us-ascii
On Tue, 1 Jul 2003 20:40:51 +0000 (UTC), "Gleb V. Kotelnitsky"
<kiz@pth.ntu-kpi.kiev.ua> wrote:
>I have a data step infile, input statements, which i want to convert to
>fopen(),fread(),fget() functions.
>the data statements are:
> infile topics pad dsd notab dlm='09'x;
> input topic $ @@;
>when i try
> %let topics=%sysfunc(fopen(&tref,s,,v));
> %sysfunc(fread(&topics));
> %sysfunc(fget(&topics,var));
>only the first record is read, after then fread() produces end of file
>warning.
>Is there a way of using functions to read such a file? (which is
>filename(tref,excel|system!topics,dde) )
I'm assuming you've only given part of your code, particularly as you
don't seem to be using sysfunc in an assignment, so the result (the
return code) would then be interpreted as a SAS statement and give an
error.
I've put some wrapping round your code and it works just fine. Maybe
you're just missing part of it. Here's my code:
filename fred '.kshrc' ;
%macro fred ;
%let topics=%sysfunc(fopen(&tref,s,,v));
%do i = 1 %to 10 ;
%let rc = %sysfunc(fread(&topics));
%let rc = %sysfunc(fget(&topics,var));
%put &var ;
%end;
%let rc = %sysfunc(close(&topics)) ;
%mend ;
%let tref = fred ;
%fred ;
--
Ace in Basel - bruce dot rogers at roche dot com
|