Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Discounting the future
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fm58hufi
Discounting the future
Commits
f2444c3d
Commit
f2444c3d
authored
2 years ago
by
fm58hufi
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
17288aea
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Do_File/Data_Transformation.do
+121
-0
121 additions, 0 deletions
Do_File/Data_Transformation.do
with
121 additions
and
0 deletions
Do_File/Data_Transformation.do
0 → 100644
+
121
−
0
View file @
f2444c3d
* SET WORKING DIRECTORY
cd
"C:\nextcloud\Discount_Paper\Revision\GitLab\"
mkdir
Working_Files
*A: TRANSFORMATION
*1. Prepare a long dataset (instead of wide) per choice
forvalues
i
=
1
/
8
{
use
"Data\ECHOES_raw_data_int_survey.dta"
,
clear
reshape
long
choice_
`i'
_
,
i
(
id
)
j
(
alt
)
rename
choice_
`i'
_
choice_
`i'
gen
id_1
=
_n
reshape
long
choice_
,
i
(
id_1
)
j
(
choice
)
save
"Working_Files\choice_`i'"
,
replace
}
clear
*2. Append dataset with all choices
forvalues
i
=
1
/
8
{
append
using
"C:\Breathing_Nature\Working_Files\choice_`i'"
}
rename
choice_
choosen
*B: VARIABLE PREPERATION
*1. Investment rate for every choice| Opt-out=0
gen
rate
=.
forvalues
choice
=
1
/
8
{
replace
rate
=
0
if
optA_rate_
`choice'
_1
==
1
&
choice
==
`choice'
&
alt
==
1
replace
rate
=
2
if
optA_rate_
`choice'
_2
==
1
&
choice
==
`choice'
&
alt
==
1
replace
rate
=
5
if
optA_rate_
`choice'
_3
==
1
&
choice
==
`choice'
&
alt
==
1
replace
rate
=
10
if
optA_rate_
`choice'
_4
==
1
&
choice
==
`choice'
&
alt
==
1
replace
rate
=
20
if
optA_rate_
`choice'
_5
==
1
&
choice
==
`choice'
&
alt
==
1
replace
rate
=
50
if
optA_rate_
`choice'
_6
==
1
&
choice
==
`choice'
&
alt
==
1
replace
rate
=
0
if
optB_rate_
`choice'
_1
==
1
&
choice
==
`choice'
&
alt
==
2
replace
rate
=
2
if
optB_rate_
`choice'
_2
==
1
&
choice
==
`choice'
&
alt
==
2
replace
rate
=
5
if
optB_rate_
`choice'
_3
==
1
&
choice
==
`choice'
&
alt
==
2
replace
rate
=
10
if
optB_rate_
`choice'
_4
==
1
&
choice
==
`choice'
&
alt
==
2
replace
rate
=
20
if
optB_rate_
`choice'
_5
==
1
&
choice
==
`choice'
&
alt
==
2
replace
rate
=
50
if
optB_rate_
`choice'
_6
==
1
&
choice
==
`choice'
&
alt
==
2
replace
rate
=
0
if
alt
==
3
}
*2. Holding period for every choice| Opt-out=0
gen
hold
=.
forvalues
choice
=
1
/
8
{
replace
hold
=
5
if
optA_hold_
`choice'
_1
==
1
&
choice
==
`choice'
&
alt
==
1
replace
hold
=
10
if
optA_hold_
`choice'
_2
==
1
&
choice
==
`choice'
&
alt
==
1
replace
hold
=
15
if
optA_hold_
`choice'
_3
==
1
&
choice
==
`choice'
&
alt
==
1
replace
hold
=
5
if
optB_hold_
`choice'
_1
==
1
&
choice
==
`choice'
&
alt
==
2
replace
hold
=
10
if
optB_hold_
`choice'
_2
==
1
&
choice
==
`choice'
&
alt
==
2
replace
hold
=
15
if
optB_hold_
`choice'
_3
==
1
&
choice
==
`choice'
&
alt
==
2
replace
hold
=
0
if
alt
==
3
}
*3. Technologie (wind=0, solar=1)|Opt-out: Since this variable does not vary between alternatives (case specific varaiable) -> opt_out=alt1=alt2
gen
tech
=.
forvalues
choice
=
1
/
8
{
forvalues
value
=
1
/
2
{
replace
tech
=
`value'
-1
if
optA_tech_
`choice'
_
`value'
==
1
&
choice
==
`choice'
&
alt
==
1
replace
tech
=
`value'
-1
if
optB_tech_
`choice'
_
`value'
==
1
&
choice
==
`choice'
&
alt
==
2
replace
tech
=
`value'
-1
if
optA_tech_
`choice'
_
`value'
==
1
&
choice
==
`choice'
&
alt
==
3
replace
tech
=
`value'
-1
if
optB_tech_
`choice'
_
`value'
==
1
&
choice
==
`choice'
&
alt
==
3
}
}
*4. Visible location (visible=1, not visible=0)| Opt-out=0
gen
loc
=.
forvalues
choice
=
1
/
8
{
replace
loc
=
1
if
optA_loc_
`choice'
_1
==
1
&
choice
==
`choice'
&
alt
==
1
replace
loc
=
0
if
optA_loc_
`choice'
_2
==
1
&
choice
==
`choice'
&
alt
==
1
replace
loc
=
1
if
optB_loc_
`choice'
_1
==
1
&
choice
==
`choice'
&
alt
==
2
replace
loc
=
0
if
optB_loc_
`choice'
_2
==
1
&
choice
==
`choice'
&
alt
==
2
replace
loc
=
0
if
alt
==
3
}
*5. Administrator (community org=1, utility comp=2, gov. entity=3)| Opt-out=4
gen
admin
=.
forvalues
choice
=
1
/
8
{
forvalues
value
=
1
/
3
{
replace
admin
=
`value'
if
optA_admin_
`choice'
_
`value'
==
1
&
choice
==
`choice'
&
alt
==
1
replace
admin
=
`value'
if
optB_admin_
`choice'
_
`value'
==
1
&
choice
==
`choice'
&
alt
==
2
replace
admin
=
4
if
alt
==
3
}
}
tab
admin
,
gen
(
admin_
)
*6. Generating group id
sort
id
choice
alt
egen
gid
=
fill
(
1
,
1
,
1
,
2
,
2
,
2
)
order
id
gid
choice
alt
choosen
rate
hold
tech
loc
admin
drop
id_1
reshape
wide
choosen
rate
hold
tech
loc
admin
*
,
i
(
gid
)
j
(
alt
)
gen
choosen
=
1
if
choosen1
==
1
replace
choosen
=
2
if
choosen2
==
1
replace
choosen
=
3
if
choosen3
==
1
gen
invest
=
bVscenariosRES
recode
invest
(
1
=
100
)
(
2
=
500
)
(
3
=
1000
)
(
4
=
2000
)
(
5
=
5000
)
keep
gid
choosen1
rate1
hold1
tech1
loc1
admin1
admin_11
admin_21
admin_31
admin_41
choosen2
rate2
hold2
tech2
loc2
admin2
admin_12
admin_22
admin_32
admin_42
choosen3
rate3
hold3
tech3
loc3
admin3
admin_13
admin_23
admin_33
admin_43
id
choice
country_sample
Q31_1
Q34
Q33_1
Q36_1
Q37_1
Q38_1
Q39_1
Q48_1
Q49_1
Q53_1
Q54_1
Q61_1
Q62
gScenarios
Q35_1
choosen
invest
export
delimited
using
"Data\ECHOES_data_wide.csv"
,
nolabel
replace
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment