DATA Step, Macro, Functions and more

how do I avoid any truncation in the fexist() function?

Reply
Frequent Contributor
Posts: 133

how do I avoid any truncation in the fexist() function?

%let fname=&dataroot&psep.st_26.csv;

%macro TABLES;

    %if %sysfunc(fexist(&fname)) %then

    %do;

        filename st_spec &fname;

            data st_26;

               infile st_spec dsd firstobs=2 truncover dlm=',';

               input date:mmddyy10.;

        run;

    %end;

    %else %do;

        %put No schedule table exists;

    %end;

%mend

In a call to the FEXIST routine, the fileref       /home/rwn/ksde/data/ftp/st_26.csv exceeds 8 characters,   and will be truncated.

Because of this, it is returned the wrong result.

how do I fix it?

Super Contributor
Posts: 349

Re: how do I avoid any truncation in the fexist() function?

Hi,

Try this...Hope it helps..

%let fname=&dataroot&psep.st_26.csv;

%macro TABLES;

filename st_spec "&fname";

    %if %sysfunc(fexist(&fname)) %then

    %do;       

            data st_26;

               infile st_spec dsd firstobs=2 truncover dlm=',';

               input date:mmddyy10.;

        run;

    %end;

    %else %do;

        %put No schedule table exists;

    %end;

%mend;

%tables;

Thanks,

Shiva

Super User
Posts: 10,035

Re: how do I avoid any truncation in the fexist() function?

Use fileexist() to replace fexist().

Ksharp

Ask a Question
Discussion stats
  • 2 replies
  • 625 views
  • 0 likes
  • 3 in conversation