Search code examples
sasinclude

Cannot open %INCLUDE file, file doesn't exist. SAS Studio


I'm writing ODS PDF program (in SAS Studio) in which I want to put code from another .sas file so that it is more readable. So I tried with %INCLUDE like this:

OPTIONS NODATE ORIENTATION=landscape;
ODS PDF FILE=savePath
    CONTENTS = no BOOKMARKLIST = no STYLE=Styles.CustomHZMO;

%INCLUDE 'Dnevni_izvjestaj_OSIGURANJE_A1_V2.sas';

ODS PDF CLOSE;

And I get the following error and warning:

WARNING: Physical file does not exist, /opt/work/SAS_work3CAC0000136A_srvlx159mih/Dnevni_izvjestaj_OSIGURANJE_A1_V2.sas.
ERROR: Cannot open %INCLUDE file Dnevni_izvjestaj_OSIGURANJE_A1_V2.sas.

Even though both of those .sas files are in the same folder. It says the same error when i give the full path of the .sas file like this:

%INCLUDE '/Projects/HZMO/Jobs/Dnevni_izvjestaj_OSIGURANJE_A1_V2.sas';

Thanks!


Solution

  • If you are on Viya and your files are saved in Viya (i.e. not physical storage mounted to the filesystem), you need to use the filesrvc access method to reference those files or folders. filesrvc is your bridge between Viya storage and SAS Studio.

    Try this instead:

    filename hzmo filesrvc
        folderpath='/Projects/HZMO/Jobs/';
    
    %include hzmo('Dnevni_izvjestaj_OSIGURANJE_A1_V2.sas');