Resources

Importing Activity Attributes (mspsae02)

/***************************************************************/
/*                                                             */
/*             S A S   S A M P L E   L I B R A R Y             */
/*                                                             */
/*    NAME: mspsae02                                           */
/*   TITLE: Importing Activity Attributes (mspsae02)           */
/* PRODUCT: OR                                                 */
/*  SYSTEM: ALL                                                */
/*    KEYS: OR                                                 */
/*   PROCS: PM, SAS/ACCESS                                     */
/*    DATA:                                                    */
/*                                                             */
/* SUPPORT:                             UPDATE:                */
/*    MISC: Example 2 from the The Microsoft Project           */
/*          Conversion Macros chapter of Project Management    */
/*                                                             */
/***************************************************************/



/****************************************************************

 This example illustrates the ability of the \%MSPTOSAS macro to
 import Microsoft Project custom fields to a SAS data set.

 ***************************************************************/
 %msptosas(mdbfile=!SASROOT\or\sasmisc\mspsas2.mdb,
                     library=work, version=2003)

 /***************************************************************
  Use the following code to create a table consisting of
  ACTIVITY and DURATION from Activity data set, E_START and
  E_FINISH from Schedule data set, and Flag1 and Text1 from
  Task_attributes data set.
 ***************************************************************/

proc sql;
   create table merged as
      select a.ACTIVITY, a.DURATION,
         b.E_START, b.E_FINISH, c.Flag1, c.Text1
      from mspout.Activity a, mspout.Schedule b,
         mspout.Task_attributes c
      where a.ACTUID=b.ACTUID=c.ACTUID
         and a.ACTIVITY is not missing;
quit;

/***************************************************************
 Note that a field is extracted and saved in the data set
 Task_attribute only when it has non-default values for at least
 one task, or if it has been renamed in Microsoft Project. If you
 are not sure if Flag1 is present in the data set Task_attribute,
 you can use the following SAS code instead.
 ***************************************************************/

%macro merge;
/* Open the data set mspout.Task_attributes and
   return an identifier &dsid. */
%let dsid=%sysfunc(open(mspout.Task_attributes));
proc sql;
    create table merged as
    select a.ACTIVITY, a.DURATION,
        b.E_START, b.E_FINISH,
        %if %sysfunc(varnum(&dsid,Flag1)) %then %do;
            c.Flag1,
        %end;
        c.Text1
    from mspout.Activity a, mspout.Schedule b,
        mspout.Task_attributes c
    where a.ACTUID=b.ACTUID=c.ACTUID
        and a.ACTIVITY is not missing;
quit;
/* Close the data set opened with the identifier &dsid. */
%let rc = %sysfunc (close (&dsid));
%mend;

%merge;