Announcement

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

  • Sorting/organizing dataset

    Hello, Please, I would like a bit of help in sorting/organizing data. I have a big data set with values organized in the following way:
    ID NAME1 PERSON_#1 NAME2 PERSON_#2 NAME3 PERSON_#3 ....
    1 A 1 H 3 M 2
    2 B 1 I 2 N 5
    3 C 3 J 1 O 5 ...

    And for each observation ID (raws), I need to check if the person 1, 2, 3, etc has the correct name compared with another dataset that is actually sorted in each ID by numerical order )=(for example in ID 1, is NAME1=1, NAME2=M, NAME3=H..)...

    I was using VLOOKUP in excel to compare both data sets, but I need first to organize each ID in such a way that I can match both data sets... I don't know if I am explaining it clearly...

    Thank you!!,

    ANTO.

  • #2
    id name1 person_#1 name2 person_#2 name3 person_#3
    1 a 1 h 3 m 2
    2 b 1 i 2 n 5
    3 c 3 j 1 o 5

    Comment


    • #3
      Welcome to the Stata Forum/ Statalist.

      Please try to share data/command under CODE delimiters or by using the SSC dataex, as suggested in the FAQ. Thanks.

      With regards to your question, on what concerns that you "need first to organize each ID in such a way that I can match both data sets", I gather the command - merge - will do the trick.

      With regards to the ID, since they differ between datatsets, I believe you need first to be sure you have a variable (a "new" id in common, if they differ) as a key.

      To end, I felt a little bit confused with your example, since name2 seems to be equal to h, not m.
      Best regards,

      Marcos

      Comment


      • #4
        Marcos gave good advice. You can rename the ID variable in one dataset so that it has the same name as in the other dataset. Then sort both datasets by ID and save them. Finally, do a 1:1 merge with ID as the key variable.

        Comment

        Working...
        X