The DATASOURCE Procedure |
Output 11.4.1 and Output 11.4.2 illustrate how to extract weekly series from a sample CITIBASE file. They also demonstrate how the OUTSELECT= option affects the contents of the auxiliary data sets.
The weekly series contained in the sample data file CITIDEMO are listed by the following statements:
options yearcutoff=1920; filename datafile "citidem.dat" RECFM=D LRECL=80; proc datasource filetype=citibase interval=week outall=citiall outby=citikey; run; title1 'Summary Information on Weekly Data for CITIDEMO File'; proc print data=citikey; run; title1 'Weekly Series Available in CITIDEMO File'; proc print data=citiall( drop=label ); run;
Daily Series Available in CITIDEMO File |
Obs | NAME | SELECTED | TYPE | LENGTH | VARNUM | BLKNUM | LABEL | FORMAT | FORMATL | FORMATD | ST_DATE | END_DATE | NTIME | NOBS | CODE | ATTRIBUT | NDEC |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | DSIUSNYDJCM | 1 | 1 | 5 | . | 42 | STOCK MKT INDEX:NY DOW JONES COMPOSITE, (WSJ) | 0 | 0 | 02DEC2019 | 09FEB2023 | 834 | 834 | DSIUSNYDJCM | 1 | 2 | |
2 | DSIUSNYSECM | 1 | 1 | 5 | . | 43 | STOCK MKT INDEX:NYSE COMPOSITE, (WSJ) | 0 | 0 | 02DEC2019 | 09FEB2023 | 834 | 834 | DSIUSNYSECM | 1 | 2 | |
3 | DSIUSWIL | 1 | 1 | 5 | . | 44 | STOCK MKT INDEX:WILSHIRE 500, (WSJ) | 0 | 0 | 02DEC2019 | 09FEB2023 | 834 | 834 | DSIUSWIL | 1 | 2 | |
4 | DFXWCAN | 1 | 1 | 5 | . | 45 | FOREIGN EXCH RATE WSJ:CANADA,CANADIAN $/U.S. $,NSA | 0 | 0 | 29NOV2019 | 09FEB2023 | 835 | 835 | DFXWCAN | 1 | 4 | |
5 | DFXWUK90 | 1 | 1 | 5 | . | 46 | FOREIGN EXCH RATE WSJ:U.K.,CENTS/POUND(90 DAY FORWARD),NSA | 0 | 0 | 29NOV2019 | 09FEB2023 | 835 | 835 | DFXWUK90 | 1 | 2 | |
6 | DSIUKAS | 1 | 1 | 5 | . | 47 | STOCK MKT INDEX:U.K. - ALL SHARES | 0 | 0 | 29NOV2019 | 09FEB2023 | 835 | 835 | DSIUKAS | 1 | 2 | |
7 | DSIJPND | 1 | 1 | 5 | . | 48 | STOCK MKT INDEX:JAPAN - NIKKEI-DOW | 0 | 0 | 29NOV2019 | 09FEB2023 | 835 | 835 | DSIJPND | 1 | 2 | |
8 | DCP05 | 1 | 1 | 5 | . | 49 | INT.RATE:5-DAY COMM.PAPER, SHORT TERM YIELD | 0 | 0 | 02DEC2019 | 22JAN2021 | 300 | 300 | DCP05 | 2 | 2 | |
9 | DCD1M | 1 | 1 | 5 | . | 50 | INT.RATE:1MO CERTIFICATES OF DEPOSIT, SHORT TERM YIELD (FBR H.15) | 0 | 0 | 02DEC2019 | 03FEB2023 | 830 | 830 | DCD1M | 1 | 2 | |
10 | DTBD3M | 1 | 1 | 5 | . | 51 | INT.RATE:3MO T-BILL, DISCOUNT YIELD (FRB H.15) | 0 | 0 | 02DEC2019 | 03FEB2023 | 830 | 830 | DTBD3M | 1 | 2 |
Note the following from Output 11.4.2:
The OUTALL= data set reports the time ranges of variables.
There are six observations in the OUTALL= data set, the same number as reported by NSERIES and NSELECT variables in the OUTBY= data set.
The VARNUM variable contains all MISSING values, since no OUT= data set is created.
Output 11.4.3 and Output 11.4.4 demonstrate how the OUTSELECT= option affects the contents of the OUTBY= and OUTALL= data sets when a KEEP statement is present. First, set the OUTSELECT= option to OFF.
filename citidemo "citidem.dat" RECFM=D LRECL=80; proc datasource filetype=citibase infile=citidemo interval=week outall=alloff outby=keyoff outselect=off; keep WSP:; run; title1 'Summary Information on Weekly Data for CITIDEMO File'; proc print data=keyoff; run; title1 'Weekly Series Available in CITIDEMO File'; proc print data=alloff( keep=name kept selected st_date end_date ntime nobs ); run;
Daily Series Available in CITIDEMO File |
Obs | NAME | KEPT | SELECTED | TYPE | LENGTH | VARNUM | BLKNUM | LABEL | FORMAT | FORMATL | FORMATD | ST_DATE | END_DATE | NTIME | NOBS | CODE | ATTRIBUT | NDEC |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | DSIUSNYDJCM | 0 | 0 | 1 | 5 | . | 42 | STOCK MKT INDEX:NY DOW JONES COMPOSITE, (WSJ) | 0 | 0 | 02DEC2019 | 09FEB2023 | 834 | 834 | DSIUSNYDJCM | 1 | 2 | |
2 | DSIUSNYSECM | 1 | 1 | 1 | 5 | . | 43 | STOCK MKT INDEX:NYSE COMPOSITE, (WSJ) | 0 | 0 | 02DEC2019 | 09FEB2023 | 834 | 834 | DSIUSNYSECM | 1 | 2 | |
3 | DSIUSWIL | 0 | 0 | 1 | 5 | . | 44 | STOCK MKT INDEX:WILSHIRE 500, (WSJ) | 0 | 0 | 02DEC2019 | 09FEB2023 | 834 | 834 | DSIUSWIL | 1 | 2 | |
4 | DFXWCAN | 0 | 0 | 1 | 5 | . | 45 | FOREIGN EXCH RATE WSJ:CANADA,CANADIAN $/U.S. $,NSA | 0 | 0 | 29NOV2019 | 09FEB2023 | 835 | 835 | DFXWCAN | 1 | 4 | |
5 | DFXWUK90 | 0 | 0 | 1 | 5 | . | 46 | FOREIGN EXCH RATE WSJ:U.K.,CENTS/POUND(90 DAY FORWARD),NSA | 0 | 0 | 29NOV2019 | 09FEB2023 | 835 | 835 | DFXWUK90 | 1 | 2 | |
6 | DSIUKAS | 0 | 0 | 1 | 5 | . | 47 | STOCK MKT INDEX:U.K. - ALL SHARES | 0 | 0 | 29NOV2019 | 09FEB2023 | 835 | 835 | DSIUKAS | 1 | 2 | |
7 | DSIJPND | 0 | 0 | 1 | 5 | . | 48 | STOCK MKT INDEX:JAPAN - NIKKEI-DOW | 0 | 0 | 29NOV2019 | 09FEB2023 | 835 | 835 | DSIJPND | 1 | 2 | |
8 | DCP05 | 1 | 1 | 1 | 5 | . | 49 | INT.RATE:5-DAY COMM.PAPER, SHORT TERM YIELD | 0 | 0 | 02DEC2019 | 22JAN2021 | 300 | 300 | DCP05 | 2 | 2 | |
9 | DCD1M | 1 | 1 | 1 | 5 | . | 50 | INT.RATE:1MO CERTIFICATES OF DEPOSIT, SHORT TERM YIELD (FBR H.15) | 0 | 0 | 02DEC2019 | 03FEB2023 | 830 | 830 | DCD1M | 1 | 2 | |
10 | DTBD3M | 0 | 0 | 1 | 5 | . | 51 | INT.RATE:3MO T-BILL, DISCOUNT YIELD (FRB H.15) | 0 | 0 | 02DEC2019 | 03FEB2023 | 830 | 830 | DTBD3M | 1 | 2 |
Setting the OUTSELECT= option ON gives results shown in Output 11.4.5 and Output 11.4.6.
filename citidemo "citidem.dat" RECFM=D LRECL=80; proc datasource filetype=citibase infile=citidemo interval=week outall=allon outby=keyon outselect=on; keep WSP:; run; title1 'Summary Information on Weekly Data for CITIDEMO File'; proc print data=keyon; run; title1 'Daily Series Available in CITIDEMO File'; proc print data=allon( keep=name kept selected st_date end_date ntime nobs ); run;
Daily Series Available in CITIDEMO File |
Obs | NAME | KEPT | SELECTED | TYPE | LENGTH | VARNUM | BLKNUM | LABEL | FORMAT | FORMATL | FORMATD | ST_DATE | END_DATE | NTIME | NOBS | CODE | ATTRIBUT | NDEC |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | DSIUSNYSECM | 1 | 1 | 1 | 5 | . | 43 | STOCK MKT INDEX:NYSE COMPOSITE, (WSJ) | 0 | 0 | 02DEC2019 | 09FEB2023 | 834 | 834 | DSIUSNYSECM | 1 | 2 | |
2 | DCP05 | 1 | 1 | 1 | 5 | . | 49 | INT.RATE:5-DAY COMM.PAPER, SHORT TERM YIELD | 0 | 0 | 02DEC2019 | 22JAN2021 | 300 | 300 | DCP05 | 2 | 2 | |
3 | DCD1M | 1 | 1 | 1 | 5 | . | 50 | INT.RATE:1MO CERTIFICATES OF DEPOSIT, SHORT TERM YIELD (FBR H.15) | 0 | 0 | 02DEC2019 | 03FEB2023 | 830 | 830 | DCD1M | 1 | 2 |
Comparison of Output 11.4.4 and Output 11.4.6 reveals the following:
The OUTALL= data set contains 10 (NSERIES) observations when OUTSELECT=OFF, and three (NSELECT) observations when OUTSELECT=ON.
The observations in OUTALL=ALLON are those for which SELECTED=1 in OUTALL=ALLOFF.
The time ranges in the OUTBY= data set are computed over all the variables (selected or not) for OUTSELECT=OFF, but only computed over the selected variables for OUTSELECT=ON. This corresponds to computing time ranges over all the series reported in the OUTALL= data set.
The variable NTIME is the number of time periods between ST_DATE and END_DATE, while NOBS is the number of observations the OUT= data set is to contain. Thus, NTIME is different depending on whether the OUTSELECT= option is set to ON or OFF, while NOBS stays the same.
The KEEP statement in the last two examples illustrates the use of an additional variable, KEPT, in the OUTALL= data sets of Output 11.4.4 and Output 11.4.6. KEPT, which reports the outcome of the KEEP statement, is only added to the OUTALL= data set when there is KEEP statement.
Adding the RANGE statement to the last example generates the data sets in Output 11.4.7 and Output 11.4.8:
filename citidemo "citidem.dat" RECFM=D LRECL=80; proc datasource filetype=citibase infile=citidemo interval=week outby=keyrange out=citiout outselect=on; keep WSP:; range from '01dec1990'd; run; title1 'Summary Information on Weekly Data for CITIDEMO File'; proc print data=keyrange; run; title1 'Weekly Data in CITIDEMO File'; proc print data=citiout; run;
Daily Data in CITIDEMO File |
Obs | DATE | DSIUSNYSECM | DCP05 | DCD1M |
---|---|---|---|---|
1 | 02DEC2019 | 142.900 | 6.81000 | 6.89000 |
2 | 03DEC2019 | 144.540 | 6.84000 | 6.85000 |
3 | 04DEC2019 | 144.820 | 6.79000 | 6.87000 |
4 | 05DEC2019 | 145.890 | 6.77000 | 6.88000 |
5 | 06DEC2019 | 137.030 | 6.73000 | 6.88000 |
6 | 09DEC2019 | 138.810 | 6.81000 | 6.89000 |
7 | 10DEC2019 | 137.740 | 6.73000 | 6.83000 |
8 | 11DEC2019 | 137.950 | 6.65000 | 6.80000 |
9 | 12DEC2019 | 137.970 | 6.67000 | 6.81000 |
The OUTBY= data set in this last example contains an additional variable NINRANGE. This variable is added since there is a RANGE statement. Its value, 15, is the number of observations in the OUT= data set. In this case, NOBS gives the number of observations the OUT= data set would contain if there were not a RANGE statement.
Copyright © SAS Institute, Inc. All Rights Reserved.