Guest User

Untitled

a guest
Dec 11th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. clear
  2. input id productid purchase
  3. 1 1 1
  4. 2 1 1
  5. 3 2 1
  6. 1 3 1
  7. end
  8.  
  9. id productid purchase
  10. 1 1 1
  11. 2 1 1
  12. 3 1 0
  13. 1 2 0
  14. 2 2 0
  15. 3 2 1
  16. 1 3 1
  17. 2 3 0
  18. 3 3 0
  19. end
  20.  
  21. qui sum id, d
  22. local obs = r(N)
  23. expand = `obs'
  24. levelsof productid, local(id)
  25. local j = 1
  26. foreach i of local id {
  27. replace productid = `i' if `j' == id
  28. local j = `j' + 1
  29. }
Add Comment
Please, Sign In to add comment