Resources

Selecting Variables Based on Geography Key Codes

/*----------------------------------------------------------------

                    SAS Sample Library

        Name: havex13.sas
 Description: Example program from SAS/ETS User's Guide,
              The SASEHAVR Interface Engine
    Title: Selecting Variables Based on Geography Key Codes
  Product: SAS/ETS Software
     Keys: SASEHAVR
    Procs:
    Notes: Read this before you run this sample.
           The database resides in the ets/sasmisc folder. You
           must copy the database to a writeable folder before
           using it. Then define your Windows system environment
           variable, HAVER_DATA, to the path of your
           writeable folder containing
           the intwkly.dat and intwkly.idx files (Haver database files).
           To assign a fileref to the external file to be processed,
           use the following form of the libname statement:

Libname lib1 sasehavr "%sysget(HAVER_DATA_NEW)"
        outselect=on
   keep="R273RF3,X924USBE,R023DF,R273G1,F023A,F158FBS,F023ACR,X156VEB,F023ACE";
----------------------------------------------------------------*/


Libname lib1 sasehavr "%sysget(HAVER_DATA_NEW)"
        outselect=on
   keep="R273RF3,X924USBE,R023DF,R273G1,F023A,F158FBS,F023ACR,X156VEB,F023ACE";

data valid1(keep=NAME SOURCE GEOG1 GEOG2 SHORTSRC LONGSRC);
   set lib1.intwkly;
run;

title1 'OUTSELECT=ON, Print the OUT= Data Set';
title2 'Shows the Values for Key Selection Variables:';
title3 'Name, Source, Geog1, Geog2, Shortsrc, Longsrc';
title4 'OUTSELECT=ON, the CONTENTS Procedure with Variable Names and Labels';
proc print data=valid1;
run;

Libname lib2 sasehavr "%sysget(HAVER_DATA_NEW)"
   geog1="156";

data valid2(
   keep=date R273RF3 X924USBE R023DF R273G1 F023A F158FBS F023ACR X156VEB F023ACE);
   set lib2.intwkly;
run;

title1 'Only one GEOG1 Code, 156, contains time series X156VEB';
title2 'Select Geography Code 1 Option:';
title3 'GEOG1= option';
title4 'Only Time Series X156VEB has Geog1 = 156';

proc contents
   data=valid2;
run;

Libname lib3 sasehavr "%sysget(HAVER_DATA_NEW)"
   geog2="299";

data valid3(
   keep=date R273RF3 X924USBE R023DF R273G1 F023A F158FBS F023ACR X156VEB F023ACE);
   set lib3.intwkly;
run;

title1 'Only one GEOG2 Code, 299, contains time series X156VEB';
title2 'Select Geography Code 2 Option:';
title3 'GEOG2= option';
title4 'Only Time Series X156VEB has Geog2 = 299';

proc contents
   data=valid3;
run;

title1 'Compare GEOG1 Code 156';
title2 'Over nonmissing values range';
title3 'With GEOG2 Code 299';
title4 'Over nonmissing values range';

proc compare listall briefsummary criterion=1.0e-5
   base=valid2(
   where=( date between '09jan1998'd and '28dec2007'd ))
   compare=valid3(
   where=( date between '09jan1998'd and '28dec2007'd ));
run;