BookmarkSubscribeRSS Feed
WorkingMan
Calcite | Level 5

Hi. I am a SAS Developer and I am planning to modify the sample stored process report in SAS forecast studio to drop a few variables/columns.

The code is stored at : 

Samples -> Import and Export -> Export as Data Set

 

However, I am pretty new to forecasting and from the source code, i cannot find the source table and open it in SAS Enterprise Guide for me to view the data and variables. Right now, I want to drop STG and ERROR variables that we see in our final output as the report generation takes more than 15 minutes to run due to its large sum of data. I believe dropping STG and ERROR in the script will shorten the time for the stored process generation. 

 

This is the full code that i got from SAS Forecast Studio, which is the default code in this tool.

/*---------------------------------------------------------------
 * Exports the data from a Forecast Studio project to a 
 * data set within an existing library. If the library is defined
 * in metadata and not pre-assigned, the new data set will also
 * be automatically registered for convenience. 
 *
 * This stored process only demonstrates the basic process for 
 * such an export operation; many variations are possible.
 *---------------------------------------------------------------
 * Parameters:
 *  [Metadata Data Set]
 *   FS_WLIBRARY           Library to hold the data set
 *   FS_DATASET            Name of the new data set
 *----------------------------------------------------------------------------
 * The output data set and map will contain the following variables:
 * 
 * _NAME_  Name of the dependent series variable
 * date    Values of the time ID variable
 * ACTUAL  Actual values of the dependent series
 * PREDICT Predicted Values of the dependent series
 * LOWER   Lower confidence limits on the predicted values
 * UPPER   Upper confidence limits on the predicted values
 * ERROR   Prediction errors of the predicted values
 * STD     Standard errors of the predicted values
 *
 * If by variables were used, they are also included:
 * <name of first by variable>  <label of first by variable>
 * ...
 * <name of last by variable>  <label of last by variable>
 *----------------------------------------------------------------------------
 *
 * Disclaimer and Warning:
 *
 *    This macro is for internal use by SAS Forecast Server software only.
 *    It makes use of undocumented aspects of SAS Forecast Server software
 *    which may be changed or removed in future releases without notice.
 *
 *    SAS programs that rely on unauthorized use of this macros or the
 *    undocumented aspects of SAS Forecast Server which it invokes will
 *    not be supported by SAS Institute.
 *
 *--------------------------------------------------------------------------*/

*ProcessBody;

/*---------------------------------------------------------*/
/*- initialize the HPF stored process support             -*/
/*---------------------------------------------------------*/
%hpfstp();

/*---------------------------------------------------------*/
/*- initialize the ODS output                             -*/
/*---------------------------------------------------------*/
%HPF_InitODSOutput();

%stpbegin;

/*---------------------------------------------------------*/
/*- convert any list parameters to space-delimited lists  -*/
/*---------------------------------------------------------*/
%HPF_MergePromptListParameters();

/*------------------------------------------------------------------*/
/*- include the LIBNAME statements and project library definitions -*/
/*------------------------------------------------------------------*/
%include "&HPF_INCLUDE";

/* temporary data set used to build the map-backing data set */
%let out=%str(work.mapdat);

/* information map data source */
%let dsrc_name = %str(&HPF_INPUT_DATASET);
%let dsrc_desc = %str(Forecast Studio results);
%let dsrc_id = %str(OUTFOR);

/* labels for information map data items */
%let ditem_name = %str(NAME);
%let ditem_time = %str(TIME);

/*---------------------------------------------------------*/
/*- assign selected metadata library                      -*/
/*---------------------------------------------------------*/
%HPF_LoadLibrary(&fs_wlibrary); 

%macro LOCAL_PUBLISH;
   /*-----------------------------------------------------------*/
   /*- non-hierarchical project                                -*/
   /*-----------------------------------------------------------*/
       %if &HPF_NUM_LEVELS = 1 %then %do;

           %let i = 1; /*- only one level -*/

       /*-------------------------------------------------------*/
       /*- determine two level data set name to append         -*/
       /*- for this level                                      -*/
       /*-------------------------------------------------------*/
           %let appendlibname =
           %str(&&HPF_LEVEL_LIBNAME&i.);
           %let appendmemname =
           %str(&&HPF_LEVEL_RECONCILE_DATASET&i.);
           %let appendset =
           %str(&appendlibname..&appendmemname.);

       /*-------------------------------------------------------*/
       /*- copy the data set                                   -*/
       /*-------------------------------------------------------*/
           %str(
           DATA &out;
           SET  &appendset;
           RUN;
           );
           %if &SYSERR^=0 & &SYSERR ^= 4 %then %do;
               %goto EXIT;
           %end;

       %end;

   /*-----------------------------------------------------------*/
   /*- unreconciled project                                    -*/
   /*-----------------------------------------------------------*/
       %else %if %symexist(HPF_RECONCILE_FORECAST) = 0 %then %do;

           %let i = 1; /*- top of the hierarchy -*/

       /*-------------------------------------------------------*/
       /*- determine two level data set name to append         -*/
       /*- for this level                                      -*/
       /*-------------------------------------------------------*/
           %let appendlibname =
           %str(&&HPF_LEVEL_LIBNAME&i.);
           %let appendmemname =
           %str(OUTFOR);
           %let appendset =
           %str(&appendlibname..&appendmemname.);

       /*-------------------------------------------------------*/
       /*- copy the top of the hiearchy                        -*/
       /*-------------------------------------------------------*/
           %str(
           DATA &out;
           SET  &appendset;
           RUN;
           );
           %if &SYSERR^=0 & &SYSERR ^= 4 %then %do;
               %put ERROR: Unable to copy project data set;
               %goto EXIT;
           %end;

       /*-------------------------------------------------------*/
       /*- for each level in the hierarchy                     -*/
       /*-------------------------------------------------------*/
           %do i = 2 %to &HPF_NUM_LEVELS;

               %let j = %eval(&i - 1);

           /*---------------------------------------------------*/
           /*- determine two level data set name to append     -*/
           /*- for this level                                  -*/
           /*---------------------------------------------------*/
               %let appendlibname =
               %str(&&HPF_LEVEL_LIBNAME&i.);
               %let appendmemname =
               %str(OUTFOR);
               %let appendset =
               %str(&appendlibname..&appendmemname.);

           /*---------------------------------------------------*/
           /*- determine the BY variable name                  -*/
           /*- for this level                                  -*/
           /*---------------------------------------------------*/
               %let byvar = %str(&&HPF_BYVAR&j.);

           /*---------------------------------------------------*/
           /*- find a unique BY variable value                 -*/
           /*- for this level                                  -*/
           /*---------------------------------------------------*/
               %HPF_InfoMap_AppendKey(dataset=&appendset,
                                      byvar=&byvar,
                                      keys=%str(+-),
                                      log=1, debug=2 );
               %if &HPF_Return_Code = ERROR %then %do;
                   %goto EXIT;
               %end;

           /*---------------------------------------------------*/
           /*- append the data set for this level              -*/
           /*- for this level                                  -*/
           /*---------------------------------------------------*/
               %HPF_InfoMap_AppendData(dataset=&out,
                                       appendset=&appendset,
                                       byvar=&byvar,
                                       key=%str(&HPF_Return_Value),
                                       log=1, debug=2 );
               %if &HPF_Return_Code = ERROR %then %do;
                   %goto EXIT;
               %end;

           %end;

       %end;

   /*-----------------------------------------------------------*/
   /*- reconciled project                                      -*/
   /*-----------------------------------------------------------*/
       %else %do;

           %let i = 1; /*- top of the hierarchy -*/

       /*-------------------------------------------------------*/
       /*- determine two level data set name to append         -*/
       /*- for this level                                      -*/
       /*-------------------------------------------------------*/
           %let appendlibname =
           %str(&&HPF_LEVEL_LIBNAME&i.);
           %let appendmemname =
           %str(&&HPF_LEVEL_RECONCILE_DATASET&i.);
           %let appendset =
           %str(&appendlibname..&appendmemname.);

       /*-------------------------------------------------------*/
       /*- copy the top of the hiearchy                        -*/
       /*-------------------------------------------------------*/
           %if &HPF_RECONCILE_LEVEL = &i %then %do;
               %str(
               DATA &out;
               SET  &appendset;
               RUN;
               );
           %end;
           %else %do;
               %str(
               DATA &out;
               SET  &appendset;
               DROP _RECONSTATUS_;
               RUN;
               );
           %end;
           %if &SYSERR^=0 & &SYSERR ^= 4 %then %do;
               %put ERROR: Unable to copy project data set;
               %goto EXIT;
           %end;

       /*-------------------------------------------------------*/
       /*- for each level in the hierarchy                     -*/
       /*-------------------------------------------------------*/
           %do i = 2 %to &HPF_NUM_LEVELS;

               %let j = %eval(&i - 1);

           /*---------------------------------------------------*/
           /*- determine two level data set name to append     -*/
           /*- for this level                                  -*/
           /*---------------------------------------------------*/
               %let appendlibname =
               %str(&&HPF_LEVEL_LIBNAME&i.);
               %let appendmemname =
               %str(&&HPF_LEVEL_RECONCILE_DATASET&i.);
               %let appendset =
               %str(&appendlibname..&appendmemname.);

           /*---------------------------------------------------*/
           /*- determine the BY variable name                  -*/
           /*- for this level                                  -*/
           /*---------------------------------------------------*/
               %let byvar = %str(&&HPF_BYVAR&j.);

           /*---------------------------------------------------*/
           /*- find a unique BY variable value                 -*/
           /*- for this level                                  -*/
           /*---------------------------------------------------*/
               %HPF_InfoMap_AppendKey(dataset=&appendset,
                                      byvar=&byvar,
                                      keys=%str(+-),
                                      log=1, debug=2 );
               %if &HPF_Return_Code = ERROR %then %do;
                   %goto EXIT;
               %end;

           /*---------------------------------------------------*/
           /*- append the data set for this level              -*/
           /*- for this level                                  -*/
           /*---------------------------------------------------*/
               %if &HPF_RECONCILE_LEVEL = &i %then %do;
                   %HPF_InfoMap_AppendData(dataset=&out,
                                           appendset=&appendset,
                                           byvar=&byvar,
                                           key=%str(&HPF_Return_Value),
                                           log=1, debug=2 );
               %end;
               %else %do;
                   %HPF_InfoMap_AppendData(dataset=&out,
                                           appendset=&appendset,
                                           byvar=&byvar,
                                           key=%str(&HPF_Return_Value),
                                           dropvars=_RECONSTATUS_,
                                           log=1, debug=2 );
               %end;
               %if &HPF_Return_Code = ERROR %then %do;
                   %goto EXIT;
               %end;

           %end;

       %end;

       /*-------------------------------------------------------*/
       /*- copy the data set                                   -*/
       /*-------------------------------------------------------*/
           %str(
           DATA %str(&fs_wlibrary..&fs_dataset.);
           SET  &out;
           RUN;
           );
           %if &SYSERR^=0 & &SYSERR ^= 4 %then %do;
               %goto EXIT;
           %end;
           
   /*-----------------------------------------------------------*/
   /*- register the output dataset in metadata                 -*/
   /*-----------------------------------------------------------*/
   %if &fs_register_data = true %then %do;
       %HPF_RegisterMetadataDataSet(&fs_wlibrary,&fs_dataset);
       
       %if &HPF_Return_Code = ERROR %then %do;
          %put &HPF_Return_Message;
          %goto EXIT;
       %end;
   %end;

   /*-----------------------------------------------------------*/
   /*- show the generated data (if requested)                  -*/
   /*-----------------------------------------------------------*/
   %if &fs_include_data = true %then %do;
      proc print data=&out;
      run;
   %end;
       
%EXIT:;

%mend LOCAL_PUBLISH;

%LOCAL_PUBLISH;

   /*-----------------------------------------------------------*/
   /*- close down                                              -*/
   /*-----------------------------------------------------------*/   
   data test;
      Message="Finished!";
   run;

   proc print data=test noobs; run;

%stpend;

 

 

I tried to put (Drop= ERROR STD) in the set statement of datastep but it throws error saying ERROR STD are not found etc.

 

How do i access to FS library in SAS EG to view the data structure for me to know the variable name?

 

 

1 REPLY 1
rajib_nath
SAS Employee

Hi @WorkingMan,

 

The easiest way to view FS data sets in SAS / EG is to run the libraries declaration file (libraries_declaration.sas). This file is located inside the project content directory. To determine the project content directory, From the project list select the project and click on Properties button. The property "Location" will show the project content directory.

 

Open the file "libraries_declaration.sas" in SAS / EG and run. The libraries used in FS project will all be assigned in the session. 

 

Regards, 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 481 views
  • 0 likes
  • 2 in conversation