Previous Page | Next Page

The DATASOURCE Procedure

Example 11.1 BEA National Income and Product Accounts

In this example, exports and imports of goods and services are extracted to demonstrate how to work with a National Income and Product Accounts (NIPA) file.

From the "Statistical Tables" published by the United States Department of Commerce, Bureau of Economic Analysis, the relation of foreign transactions in the Balance of Payments Accounts (BPA) are given in the fifth table (TABNUM=’05’) of the "Foreign Transactions" section (PARTNO=’4’). Moreover, the first line in the table gives BPAs, while the eighth gives exports of goods and services. The series names __00100 and __00800, are constructed by two underscores followed by three digits as the line numbers, and then two digits as the column numbers.

The following statements put this information together to extract quarterly BPAs and exports from a BEANIPA type file:

   /*- assign fileref to the external file to be processed --------*/
   
   filename ascifile 'beanipa.data' recfm=v lrecl=108;
   
   title1 'Relation of Foreign Transactions to Balance of Payment Accounts';
   title2 'Range from 1984 to 1989';
   
   title3 'Annual';
   proc datasource filetype=beanipa infile=ascifile
                   interval=year
                   outselect=off
                   outkey=byfor4;
   
      range from 1984 to 1989;
      keep __00100 __00800;
   
      label __00100='Balance of Payment Accounts';
      label __00800='Exports of Goods and Services';
   
      rename __00100=BPAs __00800=exports;
   run;
   
   proc print data=byfor4;
   run;
    /*- assign fileref to the external file to be processed --------*/
   
   filename ascifile 'beanipa.data' recfm=v lrecl=108;
   
   title1 'Relation of Foreign Transactions to Balance of Payment Accounts';
   title2 'Range from 1984 to 1989';
   
   title3 'Annual';
   proc datasource filetype=beanipa infile=ascifile
                   interval=year
                   outselect=off
                   outkey=byfor4
                   out=foreign4;
   
      range from 1984 to 1989;
      keep __00100 __00800;
   
      label __00100='Balance of Payment Accounts';
      label __00800='Exports of Goods and Services';
   
      rename __00100=BPAs __00800=exports;
   
   run;
   
   proc contents data=foreign4;
   run;
   proc print data=foreign4;
   run;

The results are shown in Output 11.1.1, Output 11.1.2, and Output 11.1.3.

Output 11.1.1 Listing of OUTBY=byfor4 of the BEANIPA Data
Relation of Foreign Transactions to Balance of Payment Accounts
Range from 1984 to 1989
Annual

Obs PARTNO TABNUM ST_DATE END_DATE NTIME NOBS NINRANGE NSERIES NSELECT
1 1 07 1929 1989 61 0 6 2 0
2 1 14 1929 1989 61 0 6 1 0
3 1 15 1929 1989 61 0 6 1 0
4 1 20 1967 1989 23 23 6 2 1
5 1 23 1929 1989 61 0 6 2 0
6 2 04 1929 1989 61 0 6 1 0
7 2 05 1929 1989 61 0 6 2 0
8 3 05 1929 1989 61 0 6 1 0
9 3 14 1952 1989 38 0 6 2 0
10 3 15 1952 1989 38 0 6 7 0
11 3 16 1952 1989 38 0 6 1 0
12 4 05 1946 1989 44 44 6 1 1
13 5 07 1929 1989 61 0 6 1 0
14 5 09 1929 1989 61 0 6 1 0
15 6 04 1929 1989 61 0 6 3 0
16 6 05 1929 1948 20 0 0 2 0
17 6 07 1929 1948 20 0 0 1 0
18 6 08 1929 1989 61 0 6 3 0
19 6 09 1948 1989 42 0 6 1 0
20 6 10 1929 1948 20 0 0 1 0
21 6 14 1929 1948 20 0 0 1 0
22 6 19 1929 1948 20 0 0 1 0
23 6 20 1929 1989 61 0 6 2 0
24 6 22 1929 1989 61 0 6 2 0
25 6 23 1948 1989 42 0 6 1 0
26 6 24 1948 1989 42 0 6 1 0
27 7 09 1929 1989 61 0 6 1 0
28 7 10 1929 1989 61 0 6 2 0
29 7 13 1959 1989 31 0 6 1 0

Output 11.1.2 CONTENTS of OUT=foreign4 of the BEANIPA Data
Relation of Foreign Transactions to Balance of Payment Accounts
Range from 1984 to 1989
Annual

The CONTENTS Procedure

Alphabetic List of Variables and Attributes
# Variable Type Len Format Label
3 DATE Num 4 YEAR4. Date of Observation
1 PARTNO Char 1   Part Number of Publication, IntegerPortion of the Table Number, 1-9
2 TABNUM Char 2   Table Number Within Part, DecimalPortion of the Table Number, 1-24
4 exports Num 5   Exports of Goods and Services

Output 11.1.3 Listing of OUT=foreign4 of the BEANIPA Data
Relation of Foreign Transactions to Balance of Payment Accounts
Range from 1984 to 1989
Annual

Obs PARTNO TABNUM DATE exports
1 1 20 1984 44
2 1 20 1985 53
3 1 20 1986 46
4 1 20 1987 40
5 1 20 1988 48
6 1 20 1989 47
7 4 05 1984 3835
8 4 05 1985 3709
9 4 05 1986 3965
10 4 05 1987 4496
11 4 05 1988 5520
12 4 05 1989 6262

This example illustrates the following features:

Previous Page | Next Page | Top of Page