Announcement

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

  • How to use STATA to solve this question?

    Dear Sir/Madam:
    I have two dataset. One is Hepatitis C which valuables include Case ID,Disease, Birth Date, Gender, Last Name, First Name, Age, PHN. Another dataset is HIV/AIDS which valuables include Case ID, Last name, First Name, Date of Birth, Gender, PHN. Here PHN number is unique. Now I want to know how many cases have Hepatitis C and HIV/AIDS at the same time?
    I want to use STATA to solve this question. But I don't know how to use. Can somebody help me?
    Thank you very much.

    Best regards,
    Janet

  • #2
    Code:
    * open the Hepatitis C dataset
    use “HepatitisC”, clear
    * merge it withother dataset
    merge 1:1 Case_id using “HIVAIDS”
    * keep cases that are matched
    keep if _merge==3
    drop _merge
    * tabulate
    tab HepatitisC HIVAIDS

    Comment


    • #3
      Thank you very much. But I wonder why you use merge==3?
      Thanks again.

      Comment


      • #4
        I used it to keep only the observations that appeared in both datasets. However, you can skip it.

        Comment


        • #5
          Hi Amin, I have another stupid question. I have saved HCV file into the STATA. How can I merge it to HIV/AIDS file saving in another fold? My mean is that I can only save one file into STATA, right?
          Thank you very much.

          Comment


          • #6
            1. open the HIV/AIDS file.
            2. copy the path from the Stata
            3. clear
            4. open the HepatitisC
            5. type the merge code, and use the copied path in the merge formula after 'using'



            Comment


            • #7
              But how can I copy the path from the stata? I am a newer to Stata. Thank you very much.

              Comment


              • #8
                1. In Windows, go to the folder that contains HIV/AIDS file.
                2. Right-click on the HIV/AIDS file
                3. Choose 'Properties'
                4. In the 'Location', there is a path.
                5. Choose that path and copy it
                6. Paste it in the formula

                Comment


                • #9
                  Hi Amin:
                  I have another question. I have copied the HCV dataset into the Stata. But why when I type use "HCV_2000_2017", clear I was returned file HCV_2000_2017.dta not found?
                  After I copy the path, where can I paste in in the formula? In Stata?
                  Thank you very much.

                  Best

                  Comment


                  • #10
                    I think that you should first study the basic guides or watch some tutorials before engaging in the data preparation and analysis.

                    Comment

                    Working...
                    X