10-19-2015 07:25 AM
I want to find folder name (FIGURE, LISTING, TABLE) from following code. I know that it is possible to get by using FILENAME statement but from INCLUDE statement can we get it?
%inc "H:\Analysis\Program\Figure\f_vs03.sas"; %inc "H:\Analysis\Program\Listing\l_ae01.sas"; %inc "H:\Analysis\Program\Table\t_dm01.sas";
I also know when we run interactively one by one then we can get it through SAS_EXECFILEPATH.
My objective is to find folder name becuase it is referenced to one of the macro but i need to find automatically to redirect log and output as batch program using INC statement not SYSTASK or X Command
10-19-2015 07:40 AM - edited 10-19-2015 09:31 AM
Not knowing much of your application. But I would like to go from the direction: what program do I like to execute?
Then I would register that in some kind of metadata table, or macro variable. Then I would do the execution (in your case, by %INCLUDE).
Does this makes sense?
Or, how does your application setup look like?
10-19-2015 10:50 AM
within each program standard macros are there. if we run program individually that is fine. One of the standard macro has the following code. %scan(%sysget(sas_execfilepath),-2,\) has folder name. When we call using INC statement it is taking the path where batch program is saved instead of original program
10-19-2015 07:59 AM
Personally I believe you are doing it the wrong way round. I would suggest that a robust system would be setup where these things are inferred eitehr in a setup program, or by metadata you provide up front. An example of this would be a start program which creates a libname to each of the working areas, then include would be:
That way you can always pull the pathname from a library out easily. Alternatively, that metadata could come from a main run program or some other method. Ultimately its easier to know what goes into your code, rather than at the end try to extract it, i.e. planning is more important than running. Of course, you would be following SDLC, so you would have your program plan, and know what elements combine to make the following code...
10-19-2015 10:43 AM
10-20-2015 04:09 AM
Indeed, that post was my last attempt to find a workable solution within SAS. Now, I would recommend a utility which can launch batch SAS, and that utility would handle all metedata. The whole metadata structure could do with an overhaul really.
10-19-2015 08:59 AM
Here's a simple approach. Replace the %include statements with a macro call:
%macro go_get (full_path);
Then later instead of %inc:
Now the macro can be expanded to pull out the folder name and process it any way you would like.