forked from jborowitz/x12
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adjust-win.do
54 lines (44 loc) · 1.57 KB
/
adjust-win.do
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
**********************************************************************
/*This code is an example of code that will take stata variables and seasonally*/
/*adjust them using x.py. It uses fred to import some series, but that's really*/
/*not important. */
*
/*Jeffrey Borowitz*/
/*1/26/2011*/
**********************************************************************
clear
freduse LNU03000000 UNRATENSA
save fredout.dta, replace
/*This code imports two NSA series from fred, with the freduse module*/
use fredout
keep daten LNU03000000 UNRATENSA
rename LNU03000000 num
rename UNRATENSA urate
rename daten date
/*clean data*/
format date %tdMon-CCYY
/*Important! format date like Jan-1998. If you don't do this, you would have to*/
/*modify x.py to accept other date formats. This isn't hard, but just be sure*/
/*you know what you're doing. Python's date codes can be found here:*/
/*http://docs.python.org/library/datetime.html*/
order date num urate
/*This is not necessary, but makes your .csv look how you might imagine*/
list
/*Have a look at what the data needs to look at to go into x.py*/
outsheet using unemp.csv, comma replace
/*Export to .csv*/
sort date
save unemp, replace
/*Save the NSA data in case we want to merge it back in*/
!C:\Python32\python.exe F:\x12a\stata\x.py unemp.csv unemp-sa.csv
* Use x.py as: x.py infile outfile
insheet using unemp-sa.csv, clear
/*Load in seasonally adjusted data.*/
gen date2 = date(date,"YMD")
format date2 %tdMon-CCYY
drop date
rename date2 date
* Turn the date string from the .csv into a stata date
sort date
list