<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Identifying a SAS program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-a-SAS-program/m-p/72142#M15563</link>
    <description>try &lt;BR /&gt;
1 the SYSIN option for the code invoked in batch mode, &lt;BR /&gt;
2 environment variables SAS_ExecFileName and SAS_ExecFilePath for the name of the program opened through the "file open" dialog of SAS Enhanced Editor[pre]      %let this_is= %sysget(SAS_ExecFilePath) %sysfunc(getoption(sysin)); &lt;BR /&gt;
      option symbolgen ;&lt;BR /&gt;
      footnote2 "&amp;amp;this_is   ";[/pre]&lt;BR /&gt;
Otherwise you could make your own arrangements (like filling a macro variable like &amp;amp;this_prog_is).&lt;BR /&gt;
 &lt;BR /&gt;
good luck&lt;BR /&gt;
 &lt;BR /&gt;
PeterCV</description>
    <pubDate>Tue, 03 Feb 2009 16:11:35 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-02-03T16:11:35Z</dc:date>
    <item>
      <title>Identifying a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-a-SAS-program/m-p/72141#M15562</link>
      <description>I am looking for a piece of code that could indentify the SAS program generating an output (eg an output generated by proc tabulate), and put the path and program name in a footnote to the output.&lt;BR /&gt;
&lt;BR /&gt;
Mxller</description>
      <pubDate>Tue, 03 Feb 2009 15:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-a-SAS-program/m-p/72141#M15562</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-03T15:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-a-SAS-program/m-p/72142#M15563</link>
      <description>try &lt;BR /&gt;
1 the SYSIN option for the code invoked in batch mode, &lt;BR /&gt;
2 environment variables SAS_ExecFileName and SAS_ExecFilePath for the name of the program opened through the "file open" dialog of SAS Enhanced Editor[pre]      %let this_is= %sysget(SAS_ExecFilePath) %sysfunc(getoption(sysin)); &lt;BR /&gt;
      option symbolgen ;&lt;BR /&gt;
      footnote2 "&amp;amp;this_is   ";[/pre]&lt;BR /&gt;
Otherwise you could make your own arrangements (like filling a macro variable like &amp;amp;this_prog_is).&lt;BR /&gt;
 &lt;BR /&gt;
good luck&lt;BR /&gt;
 &lt;BR /&gt;
PeterCV</description>
      <pubDate>Tue, 03 Feb 2009 16:11:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-a-SAS-program/m-p/72142#M15563</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-03T16:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying a SAS program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-a-SAS-program/m-p/72143#M15564</link>
      <description>I wrote a macro to do this using titles. It may be overkill, but the issue I ran into was existing titles that were defined, avoiding duplication of the id text and the limitation on the number of title lines available. I am including my macro below. It should be relatively easy to change to use footnotes instead of titles chaning the references TYPE='T' to TYPE='F'.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/*******************************************************************/&lt;BR /&gt;
/*Purpose:                                                         */&lt;BR /&gt;
/*This macro puts the name of the currently executing program name */&lt;BR /&gt;
/*to the current out put destination using a title statement       */&lt;BR /&gt;
/* Programmer: Ward Ballard Sep 2007                               */&lt;BR /&gt;
/*******************************************************************/&lt;BR /&gt;
/* Use:                                                            */&lt;BR /&gt;
/* Syntax %sourceid; Currently no options or parameters            */&lt;BR /&gt;
/* included in the SAS code file. The file MUST have a name        */&lt;BR /&gt;
/* (i.e. saved) at some time prior to the code execution.          */&lt;BR /&gt;
/* Needs to be executed from the Enhanced Program Editor.          */&lt;BR /&gt;
/* Best if placed in a directory included in AUTOCALL, probably the*/&lt;BR /&gt;
/* initial data directory.                                         */&lt;BR /&gt;
/* Place the call AFTER any desired titles and BEFORE any proc     */&lt;BR /&gt;
/* step as this includes proc calls.                               */&lt;BR /&gt;
/* Only works where TITLE is used.                                 */&lt;BR /&gt;
/* If the user creates a new title with a gap from the last time   */&lt;BR /&gt;
/* the macro is called, i.e. Title xxx; %SOURCEID; TITLE5 YYY.     */&lt;BR /&gt;
/* The previous call to sourceid is still a valid title and the    */&lt;BR /&gt;
/* titles for both instance will appear.                           */&lt;BR /&gt;
/* I have not tested how this will work with %INCLUDE files, but   */&lt;BR /&gt;
/* I think if the macro is called within the included file that is */&lt;BR /&gt;
/* the name reported.                                              */&lt;BR /&gt;
/*******************************************************************/&lt;BR /&gt;
/*Challenges: Making sure that theren't aren't blank title lines   */&lt;BR /&gt;
/* and that there is a way of handling 10 existing title lines and */&lt;BR /&gt;
/* that we don't get redundant source statements if executed many  */&lt;BR /&gt;
/* times.                                                          */&lt;BR /&gt;
/* Initially attempted to use other methods of getting the number  */&lt;BR /&gt;
/* of assigned titles but the dataset functions do not work        */&lt;BR /&gt;
/* as needed with the SASHELP.VTITLE data view that has title info */&lt;BR /&gt;
/*******************************************************************/&lt;BR /&gt;
/* this could be modified to do FOOTNOTES instead by changing the  */&lt;BR /&gt;
/* places where TYPE='T' to TYPE='F'. Remember that Footnotes will */&lt;BR /&gt;
/* be at bottom of listing in the output window and will tend to   */&lt;BR /&gt;
/* pad the output lines used to match pagesize. This can result in */&lt;BR /&gt;
/* many blank lines depending upon your current pagesize setting.  */&lt;BR /&gt;
/* Each ODS output type seems to treat footnotes slightly different*/&lt;BR /&gt;
/* You have been warned.                                           */&lt;BR /&gt;
/*******************************************************************/&lt;BR /&gt;
/* If you use "Source file:" as part of your titles for some reason*/&lt;BR /&gt;
/* replace that text with something else in the macro below (could */&lt;BR /&gt;
/* be done as a parameter but be carefull of frequent changes)     */&lt;BR /&gt;
/*******************************************************************/&lt;BR /&gt;
/* example use:                                                    */&lt;BR /&gt;
/*                                                                 */&lt;BR /&gt;
/* Title1 "A summary of some variables by some others";            */&lt;BR /&gt;
/* Title2 "Among some demographic groups";                         */&lt;BR /&gt;
/* %sourceid; (must come after the title statements &amp;amp; before proc) */&lt;BR /&gt;
/*                                                                 */&lt;BR /&gt;
/* Proc Freq data=mydataset;                                       */&lt;BR /&gt;
/*    table (demo1 demo2)*(var1*var2 var1*var3);                   */&lt;BR /&gt;
/* run;                                                            */&lt;BR /&gt;
/*                                                                 */&lt;BR /&gt;
/* Result:                                                         */&lt;BR /&gt;
/*                                                                 */&lt;BR /&gt;
/* A summary of some variables by some others                      */&lt;BR /&gt;
/* Among some demographic groups                                   */&lt;BR /&gt;
/* Source file: D:\Data\project\codefile.sas                       */&lt;BR /&gt;
/*                                                                 */&lt;BR /&gt;
/* (Freq tables)                                                   */&lt;BR /&gt;
/*                                                                 */&lt;BR /&gt;
/*******************************************************************/&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro SourceId;&lt;BR /&gt;
   %local nobs tnobs ttext pos; &lt;BR /&gt;
   proc sql NOPRINT;&lt;BR /&gt;
      select max (number) into :nobs&lt;BR /&gt;
      from SASHELP.VTITLE&lt;BR /&gt;
      where type='T';&lt;BR /&gt;
   QUIT; &lt;BR /&gt;
   proc sql NOPRINT;&lt;BR /&gt;
      select TEXT into :TTEXT&lt;BR /&gt;
      from SASHELP.VTITLE&lt;BR /&gt;
      WHERE NUMBER=&amp;amp;nobs and type='T';&lt;BR /&gt;
   QUIT; &lt;BR /&gt;
   %let nobs=%left(&amp;amp;nobs);&lt;BR /&gt;
   %*Check to see if the title already starts with Source file:;&lt;BR /&gt;
   %*If so, then reuse that title line. This improves utility  ;&lt;BR /&gt;
   %*by not creating duplicate titles. Note that this does not ;&lt;BR /&gt;
   %*check to see if the source is actually the same as you    ;&lt;BR /&gt;
   %*want to change the title when the file changes.           ;&lt;BR /&gt;
&lt;BR /&gt;
   %put Initial nobs is &amp;amp;nobs ttext is &amp;amp;ttext;&lt;BR /&gt;
   %let pos = %index(&amp;amp;ttext,Source file:);&lt;BR /&gt;
   %if &amp;amp;pos = 1 %then %do; %* previous title was only source file cite;&lt;BR /&gt;
      %let ttext = Source file: %sysget(SAS_EXECFILEPATH);&lt;BR /&gt;
      title&amp;amp;nobs "&amp;amp;ttext" ;&lt;BR /&gt;
   %end;&lt;BR /&gt;
   %Else %if &amp;amp;pos &amp;gt; 1 %then %do; %* previous title had other text with source file;&lt;BR /&gt;
         %* the following line has an extr ) at the end that is treated as text;&lt;BR /&gt;
         %* this is to maintain the appearance as title10 statment below, the start parenthese is in the substr ;&lt;BR /&gt;
         %let ttext = %substr(&amp;amp;ttext,1,%eval(&amp;amp;pos-1)) Source file: %sysget(SAS_EXECFILEPATH));&lt;BR /&gt;
         title&amp;amp;nobs "&amp;amp;ttext";&lt;BR /&gt;
   %end;&lt;BR /&gt;
   %else %do; %* The text Source file is not in the title;&lt;BR /&gt;
&lt;BR /&gt;
      %if &amp;amp;nobs lE 0 %then %let nobs=1;&lt;BR /&gt;
      %if &amp;amp;nobs &amp;lt; 10 %then %DO;&lt;BR /&gt;
         %LET NOBS = %EVAL(&amp;amp;NOBS + 1);&lt;BR /&gt;
         title&amp;amp;nobs "Source file: %sysget(SAS_EXECFILEPATH)" ;&lt;BR /&gt;
      %END;&lt;BR /&gt;
      %IF &amp;amp;NOBS = 10 %THEN %DO; &lt;BR /&gt;
      %* GET THE TEXT OF THE TENTH TITLE ELEMENT AND APPEND THE PATH TEXT;&lt;BR /&gt;
         TITLE10 "%SYSFUNC(STRIP(&amp;amp;TTEXT)) (Source file: %sysget(SAS_EXECFILEPATH))";&lt;BR /&gt;
      %END;&lt;BR /&gt;
   %end;&lt;BR /&gt;
%mend;</description>
      <pubDate>Fri, 06 Feb 2009 18:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-a-SAS-program/m-p/72143#M15564</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2009-02-06T18:17:40Z</dc:date>
    </item>
  </channel>
</rss>

