DATASOURCE Procedure

Example 12.8 Annual COMPUSTAT Data Files, V9.2 New Filetype CSAUC3

(View the complete code for this example.)

Annual COMPUSTAT data in Universal Character format are read for PRICES since the year 2002, so that the desired output show the PRICE (HIGH), PRICE (LOW), and PRICE (CLOSE) for each company.

filename datafile "%sysget(DATASRC_DATA)csaucy3.dat" RECFM=F LRECL=13612;
/*--------------------------------------------------------------*
 * create OUT=csauy3 data set with ASCII 2003 Industrial Data   *
 * compare it with the OUT=csauc data set created by DATA STEP  *
 *--------------------------------------------------------------*/

proc datasource filetype=csaucy3 ascii
                infile=datafile
                interval=year
                outselect=on
                outkey=y3key
                out=csauy3;

     keep data197-data199 label;
     range from 2002;
run;

proc sort
   data=csauy3 out=csauy3;
   by dnum cnum cic file zlist smbl xrel stk;
run;

title1 'Price, High, Low and Close for Range from 2002';
proc contents data=csauy3;
run;

proc print data=csauy3;
run;

Output 12.8.1 shows information on the contents of the CSAUY3 data set, while Output 12.8.2 shows a listing of the CSAUY3 data set.

Output 12.8.1: Listing of the Contents of OUT=CSAUY3 Data Set

Price, High, Low and Close for Range from 2002

The CONTENTS Procedure

Alphabetic List of Variables and Attributes
#VariableTypeLenFormatLabel
3CICChar3  
2CNUMChar6  
11COUNTYNum5  
13CPSPINChar1  
15CSSPIIChar1  
14CSSPINChar2  
18DATA197Num5 Price - Fiscal Year - High ($&c,NA)
19DATA198Num5 Price - Fiscal Year - Low ($&c,NA)
20DATA199Num5 Price - Close - Fiscal Year-End ($&c,NA)
17DATENum4YEAR4.Date of Observation
1DNUMNum5  
9DUPFILENum5  
16EINChar10  
4FILENum5  
12FINCNum5  
6SMBLChar8  
10STATENum5  
8STKNum5  
7XRELNum5  
5ZLISTNum5  


Output 12.8.2: Listing of the OUT=CSAUY3 Data Set

Price, High, Low and Close for Range from 2002

ObsDNUMCNUMCICFILEZLISTSMBLXRELSTKDUPFILESTATECOUNTYFINCCPSPINCSSPINCSSPIIEINDATEDATA197DATA198DATA199
13089899896104111TUP4440012950110 36-4062333200224.99014.400015.0800
23089899896104111TUP4440012950110 36-40623332003...
33674032654105111ADI9280025210110 04-2348234200248.84017.880026.8000
43674032654105111ADI9280025210110 04-23482342003...
5384205380110615AVR00025210   06-117405320021.5000.22000.2300
6384205380110615AVR00025210   06-11740532003...
76035149547101325CAVB000471490   62-1721072200214.00011.581013.3400
86035149547101325CAVB000471490   62-17210722003...
96211617446448111MWD7250036610110136-3145972200260.02028.801045.2400
106211617446448111MWD7250036610110136-31459722003...
11672609247M10514BMN00034130    200211.05010.370011.0100
12672609247M10514BMN00034130    2003...
13701154021P20515LGN000131210   52-2093696200213.8941.008413.8940
14701154021P20515LGN000131210   52-20936962003...
15737035921T10815FNT00036870   13-395028320020.4400.12000.2600
16737035921T10815FNT00036870   13-39502832003...
177370459200101111IBM90300361190110113-08719852002126.39054.010077.5000
187370459200101111IBM90300361190110113-08719852003...
19781259161010014MGM0006370   95-4605850200223.2509.000013.0000
20781259161010014MGM0006370   95-46058502003...


Note that annual COMPUSTAT data are available in either IBM 360/370 General format or Universal Character format. The first example expects an IBM 360/370 General format file since the FILETYPE= is set to CSAIBM, while the second example uses a Universal Character format file (FILETYPE=CSAUC).

Last updated: June 19, 2025