-
Notifications
You must be signed in to change notification settings - Fork 0
/
0_create_aux_data.sas
72 lines (56 loc) · 2.06 KB
/
0_create_aux_data.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* *************************************************************************/
/* CREATED BY: Jesse Blocher (UNC-Chapel Hill)
/* MODIFIED BY:
/* DATE CREATED: July 2010
/* PROG NAME: create_aux_data.sas
/* Project: Morningstar US Open Ended Funds Portfolio Data Merge
/* This File: Converts Type Codes to real variable names, enters sector codes
/************************************************************************************/
%include 'morn_merge_header.sas'; *header file with basic options and libraries;
/* Datasets required to run:
* morn.portfolio_type_codes : Excel Sheet converted to SAS via Stat Transfer
*/
/* Datasets Produced:
* morn.portfolio_type_codes_renamed : Cleaned and renamed data for use
* morn.sector_codes : Sector codes entered and small data set created
*/
proc contents data = morn.portfolio_type_codes;
proc print data = morn.portfolio_type_codes;
run;
data morn.portfolio_type_codes_renamed (drop = c1 c2);
set morn.portfolio_type_codes;
*because stattransfer picked up the header row;
if c1 = 'Type Code' then delete;
type_cd = substr(c1,1,2);
label type_cd = 'Asset Type Code';
type_name = c2;
label type_name = 'Asset Type Name';
run;
proc contents data = morn.portfolio_type_codes_renamed;
proc print data = morn.portfolio_type_codes_renamed;
run;
data temp;
infile datalines delimiter=',';
input sector_code_char $2. sector_name $20.;
datalines;
1 Software
2 Hardware
3 Media
4 Telecommunication
5 Healthcare
6 Consumer Service
7 Business Service
8 Financial Service
9 Consumer Goods
10Industrial Materials
11Energy
12Utilities
;
run;
data morn.sector_codes (drop = sector_code_char);
set temp;
sector_code=input(sector_code_char,best8.);
run;
proc contents data = morn.sector_codes;
proc print data = morn.sector_codes;
run;