Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dummy variable zip codes

    Hey everyone,

    I've a question concerning the creation of a dummy variable. For my thesis I want to look whether being in a certain postal area differs significantly. To do so I want to create a dummy variable which needs to 1 if it ends with 1 or 2 and 0 for all others. Can someone tell me how I can create this variable?

    zip is the original variable
    zip12 needs to be the new one, =1 if zip ends with 1 or 2, =0 if other

    Thanks in advance

  • #2
    It would be more helpful if you post some excerpts from your data. In the following example, I assume your zip code is numeric, If it is already string it is simpler :
    Code:
    g zip12=inlist(substr(string(zip_var),-1,.),"1","2")

    Comment


    • #3
      I finally figured it out. Did it with several commands instead of 1, I think I made the mistake there. Thanks anyway :D

      Comment

      Working...
      X