fork download
  1. # Simulate data
  2. clear
  3. set obs 100
  4. set seed 321
  5.  
  6. matrix C = (1, .7 \ .7, 1)
  7.  
  8. corr2data x y, means(50 70) corr(C)
  9.  
  10. gen z=x
  11.  
  12. sum x y z
  13.  
  14. #Modify z variable
  15. replace z=z+5 if y>70
  16. replace z=z-5 if y<70
  17. replace z=z+1 if x>51
  18. replace z=z-1 if x<49
  19. replace z=z-2 if x<51 & x>49 & z<50
  20. replace z=z+2 if x<51 & x>49 & z>50
  21. replace z=z+1 if x<49
  22. replace z=z-3 if x>=50.4 & x<=50.6 & z>50
  23. replace z=z-2 if x<=49.4 & z>50
  24. replace z=z+3 if x>=50.4 & x<=50.6 & z<50
  25. replace z=z+2 if x>=48.5 & x<=49 & z<50
  26. replace z=z+2 if x>=48.1 & x<=48.5 & z<50<?php
  27.  
  28. // your code goes here
Success #stdin #stdout 0.02s 25644KB
stdin
Standard input is empty
stdout
# Simulate data
clear
set obs 100
set seed 321

matrix C = (1, .7 \ .7, 1)

corr2data x y, means(50 70) corr(C)

gen z=x

sum x y z

#Modify z variable
replace z=z+5 if y>70
replace z=z-5 if y<70
replace z=z+1 if x>51
replace z=z-1 if x<49
replace z=z-2 if x<51 & x>49 & z<50
replace z=z+2 if x<51 & x>49 & z>50
replace z=z+1 if x<49 
replace z=z-3 if x>=50.4 & x<=50.6 & z>50
replace z=z-2 if x<=49.4 & z>50
replace z=z+3 if x>=50.4 & x<=50.6 & z<50
replace z=z+2 if x>=48.5 & x<=49 & z<50
replace z=z+2 if x>=48.1 & x<=48.5 & z<50