Dear all,
I am new to STATA and looking for a command to sum specific observations within one variable of my dataset.
I have the following dataset:
* Example generated by -dataex-. For more info, type help dataex
clear
input str22 fuel double allocated_output
"Cluster" 1107364
"Hard coal" 42241315.596366525
"Hydro" 83835
"Lignite" 27428060.908967614
"Liquid" 667447
"N/A" 20886959.56677246
"Natural gas" 11916637
"Nuclear" 4076733
"RES" 124680
"Photovoltaik" 31
"Pumped storage" 3350304.921482086
"Wind" 9916255
end
[/CODE]
My goal is to sum the "allocated_output" for some observations within my "fuel" variable. For example Photovoltaik and Wind. I tried:
gen zero-emissions = sum(allocated_output) if fuel==("Photovoltaik, "Wind")]
However, it does not work and tells me:
invalid syntax
r(198);
Can someone help me to find the correct command? I appreciate your help.
Best,
Bianca
I am new to STATA and looking for a command to sum specific observations within one variable of my dataset.
I have the following dataset:
* Example generated by -dataex-. For more info, type help dataex
clear
input str22 fuel double allocated_output
"Cluster" 1107364
"Hard coal" 42241315.596366525
"Hydro" 83835
"Lignite" 27428060.908967614
"Liquid" 667447
"N/A" 20886959.56677246
"Natural gas" 11916637
"Nuclear" 4076733
"RES" 124680
"Photovoltaik" 31
"Pumped storage" 3350304.921482086
"Wind" 9916255
end
[/CODE]
My goal is to sum the "allocated_output" for some observations within my "fuel" variable. For example Photovoltaik and Wind. I tried:
gen zero-emissions = sum(allocated_output) if fuel==("Photovoltaik, "Wind")]
However, it does not work and tells me:
invalid syntax
r(198);
Can someone help me to find the correct command? I appreciate your help.
Best,
Bianca
Comment