Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65593

How to create variables that are interactions of observations

$
0
0
Hi Statalist,

I have data on the output of a number of workers in a firm for different processes. Each process has a target output. My goal is to divide each observation by the target output of that process. I am fairly confident I am taking the wrong approach to this but am not too sure how to resolve it! Here is a snippet of the dataset.


Code:
clear
input str4 firm long id byte a int(collarmake acollartopstitch bandrulling) byte b
"SMV"      . . 120 120 150 .
"7010" 30151 . 120 100   . .
"7010" 30153 .   .   .   . .
"7010" 30171 .  70   .   . .
"7010" 30211 . 100   . 120 .
"7010" 30214 .   . 100 120 .
"7010" 40456 .   .   .   . .
"7010" 50790 .   .   .   . .
"7010" 51242 .   .   .   . .
"7010" 51726 .   . 120   . .
end
The first row shows the SMV's which are the outputs. I wish to create new variables for each process that represents output as a % of the target. For example, pc_collarmake variable would have, for id 30151, 120/120 = 1. I expect it to be something similar to this but I can't figure out what

Code:
foreach x of varlist a - b {
   gen `x'_pc = `x' / firm[`SMV']
   }
Sorry if this isnt explained too well, and thanks in advance for any help!

Best,
Chris

Viewing all articles
Browse latest Browse all 65593


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>