As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Modifying programs for SEG usage

From sasCommunity
Jump to: navigation, search

This article is a chronicle of modifications I made to projects and site utilities where I had previously run all the programs in batch.

Acronymns:

Using Environmental Variables

First thing: SEG is a session and doesn't know where your project is.

First choice: macro variables or environment variables?

I started out adding two macro variables:

  1. _Drive
  2. _Project
%Let _Drive   = \\MyCompany\projects\Stat_Helpdesk;
%Let _Project = GAL;
 
*old: for batch, using relative folder-references;
*filename Project  '.';*here: project;
*filename SiteIncl ('.' 
                    '..\..\SAS-site\includes');
*there: SAS-site is a sibling folder of this project;
*e.g.:
C:\SAS-Projects
C:\SAS-Projects\GAL
C:\SAS-Projects\SAS-site
;
 
* for SEG;
filename Project   "&_Drive.\&_Project.\sas";
filename SiteIncl ("&_Drive.\&_Project.\sas"
                   "&_Drive.\SAS-site\includes");

Note: all SEG macro variables begin with underline (_).

All the changes I need to make were changing relative folder references to hard-coded references. Since these are always operating-system specific I decided to use environment variables instead.

options set = evar 'c:\temp';
%put note evar: %sysget(evar);
 
DATA _Null_;
file "!evar\temp.txt";
put 'testing';
stop;
run;
 
proc options define value option=set;
run;

19   options set = evar 'c:\temp';
20   %put note evar: %sysget(evar);
note evar: c:\temp

...

NOTE: The file "!evar\temp.txt" is:
      Filename=c:\temp\temp.txt, ...
...

Option Value Information For SAS Option SET
    Value: [FT15F001 = 'FT15F001.DAT'] 
... Big Snip ...
[evar = 'c:\temp'] 
* note.1: equals sign before evar-name 
          value in single- or double-quotes;
* note.2: only one evar per file- or folder-specification:
  this will not work:
filename Project ("!Prj_Drive\!Prj_Name\sas";
 
options set= Prj_Drive '\\MyCompany\project\Stat_Helpdesk';
options set= Prj_Name  '\\MyCompany\project\Stat_Helpdesk\GAL';
*usage:;
filename Project   "!Prj_Name\sas";
filename SiteIncl ("!Prj_Name\sas"
                   "!Prj_Drive\SAS-site\includes");
*checking;
filename Project  list;
filename SiteIncl list;
26         filename Project   "!Prj_Name\sas";
27         filename SiteIncl ("!Prj_Name\sas"
28                            "!Prj_Drive\SAS-site\includes");
29         filename Project  list;
NOTE: Fileref= PROJECT
      Physical Name= \\MyCompany\project\Stat_Helpdesk\GAL\sas
30         filename SiteIncl list;
NOTE: Fileref= SITEINCL
      Physical Name= \\MyCompany\project\Stat_Helpdesk\GAL\sas
      Physical Name= \\MyCompany\project\Stat_Helpdesk\SAS-site\includes
 

References

--macro maven == the radical programmer 16:09, 11 April 2012 (EDT)