Example 34.5 Creating a View Using the SQL Procedure and SASEFAME
The following statements create a view of OECD data by using the SQL procedure’s FROM and USING clauses as shown in Output 34.5.1. Refer to the BASE SAS Procedures Guide for details on SQL views.
title1 'famesql5: PROC SQL Dual Embedded Libraries w/ FAME option';
options validvarname=any;
%let FAME=%sysget(FAME);
%put(&FAME);
%let FAMETEMP=%sysget(FAME_TEMP);
%put(&FAMETEMP);
title2 'OECD1: Dual Embedded Library Allocations with FAME Option';
proc sql;
create view fameview as
select date, 'fin.herd'n
from lib1.oecd1
using libname lib1 sasefame "%sysget(FAME_DATA)"
convert=(tech=constant freq=annual),
libname temp "%sysget(FAME_TEMP)";
quit;
title2 'OECD1: Print of View from Embedded Library with FAME Option';
proc print data=fameview;
run;
Output 34.5.1
Printout of the FAME View of OECD Data
1985 |
1097.00 |
1986 |
1234.00 |
1987 |
1401.30 |
1988 |
1602.00 |
1989 |
1725.50 |
1990 |
1839.00 |
1991 |
. |
The following statements create a view of DRI Basic Economic data by using the SQL procedure’s FROM and USING clauses as shown in Output 34.5.2.
title2 'SUBECON: Dual Embedded Library Allocations with FAME Option';
options validvarname=any;
%let FAME=%sysget(FAME);
%put(&FAME);
%let FAMETEMP=%sysget(FAME_TEMP);
%put(&FAMETEMP);
proc sql;
create view fameview as
select date, gaa
from lib1.subecon
using libname lib1 sasefame "%sysget(FAME_DATA)"
convert=(tech=constant freq=annual),
libname temp "%sysget(FAME_TEMP)";
quit;
title2 'SUBECON: Print of View from Embedded Library with FAME Option';
proc print data=fameview;
run;
Output 34.5.2
Printout of the FAME View of DRI Basic Economic Data
1946 |
. |
1947 |
. |
1948 |
23174.00 |
1949 |
19003.00 |
1950 |
24960.00 |
1951 |
21906.00 |
1952 |
20246.00 |
1953 |
20912.00 |
1954 |
21056.00 |
1955 |
27168.00 |
1956 |
27638.00 |
1957 |
26723.00 |
1958 |
22929.00 |
1959 |
29729.00 |
1960 |
28444.00 |
1961 |
28226.00 |
1962 |
32396.00 |
1963 |
34932.00 |
1964 |
40024.00 |
1965 |
47941.00 |
1966 |
51429.00 |
1967 |
49164.00 |
1968 |
51208.00 |
1969 |
49371.00 |
1970 |
44034.00 |
1971 |
52352.00 |
1972 |
62644.00 |
1973 |
81645.00 |
1974 |
91028.00 |
1975 |
89494.00 |
1976 |
109492.00 |
1977 |
130260.00 |
1978 |
154357.00 |
1979 |
173428.00 |
1980 |
156096.00 |
1981 |
147765.00 |
1982 |
113216.00 |
1983 |
133495.00 |
1984 |
146448.00 |
1985 |
128521.99 |
1986 |
111337.99 |
1987 |
160785.00 |
1988 |
210532.00 |
1989 |
201637.00 |
1990 |
218702.00 |
1991 |
210666.00 |
1992 |
. |
1993 |
. |
The following statements create a view of the DB77 database by using the SQL procedure’s FROM and USING clauses, as shown in Output 34.5.3.
title2 'DB77: Dual Embedded Library Allocations with FAME Option';
options validvarname=any;
%let FAME=%sysget(FAME);
%put(&FAME);
%let FAMETEMP=%sysget(FAME_TEMP);
%put(&FAMETEMP);
proc sql;
create view fameview as
select date, ann, 'qandom.x'n
from lib1.db77
using libname lib1 sasefame "%sysget(FAME_DATA)"
convert=(tech=constant freq=annual),
libname temp "%sysget(FAME_TEMP)";
quit;
title2 'DB77: Print of View from Embedded Library with FAME Option';
proc print data=fameview;
run;
Output 34.5.3
Printout of the FAME View of DB77 Data
1959 |
. |
0.56147 |
1960 |
. |
0.51031 |
1961 |
. |
. |
1962 |
. |
. |
1963 |
. |
. |
1964 |
. |
. |
1965 |
. |
. |
1966 |
. |
. |
1967 |
. |
. |
1968 |
. |
. |
1969 |
. |
. |
1970 |
. |
. |
1971 |
. |
. |
1972 |
. |
. |
1973 |
. |
. |
1974 |
. |
. |
1975 |
. |
. |
1976 |
. |
. |
1977 |
. |
. |
1978 |
. |
. |
1979 |
. |
. |
1980 |
100 |
. |
1981 |
101 |
. |
1982 |
102 |
. |
1983 |
103 |
. |
1984 |
104 |
. |
1985 |
105 |
. |
1986 |
106 |
. |
1987 |
107 |
. |
1988 |
109 |
. |
1989 |
111 |
. |
The following statements create a view of the DRI economic database by using the SQL procedure’s FROM and USING clauses, as shown in Output 34.5.4.
title2 'DRIECON: Dual Embedded Library Allocations with FAME Option';
options validvarname=any;
%let FAME=%sysget(FAME);
%put(&FAME);
%let FAMETEMP=%sysget(FAME_TEMP);
%put(&FAMETEMP);
proc sql;
create view fameview as
select date, husts
from lib1.driecon
using libname lib1 sasefame "%sysget(FAME_DATA)"
convert=(tech=constant freq=annual)
range='01jan1980'd - '01jan2006'd ,
libname temp "%sysget(FAME_TEMP)";
quit;
title2 'DRIECON: Print of View from Embedded Library with FAME Option';
proc print data=fameview;
run;
Note that the SAS option VALIDVARNAME=ANY was used at the beginning of this example due to special characters being present in the time series names. The output from this example shows how each FAME view is the output of the SASEFAME engine’s processing. Note that different engine options could have been used in the USING LIBNAME clause if desired.
Output 34.5.4
Printout of the FAME View of DRI Basic Economic Data
1980 |
1.29990 |
1981 |
1.09574 |
1982 |
1.05862 |
1983 |
1.70580 |
1984 |
1.76351 |
1985 |
1.74258 |
1986 |
1.81205 |
1987 |
1.62914 |
1988 |
1.48748 |
1989 |
1.38218 |
1990 |
1.20161 |
1991 |
1.00878 |
1992 |
1.20159 |
1993 |
1.29201 |
1994 |
1.44669 |
1995 |
1.36158 |
1996 |
1.46952 |
1997 |
1.47760 |
1998 |
1.56250 |