Announcement

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

  • How to make one variable from three variables after putting the three variables in long format

    Question 1:
    I have five string variables:
    Path1 Path2 Path3 Path4 Path5. These Path variables are in wide format and contain the same categories which are medicine A, medicine B, medicine C or medicine D. I have 1000 subjects in my dataset. I want to make a new variable that is a composite of patients walking three paths or more i.e. Path≥3 and I want to keep the Path1 and Path2 variable.
    How do I do this? Do I need to reshape my data in long format? If so, do I use the "j' as I see that this is used for many things of this nature.

    Question 2:
    How do I make a Path1 and Path2 variable in long format as I have to test for associations between Path1 with Y, Path2 with Y, Path≥3 with Y.

    Ps. one patient can have observations in all five Path variables, some in three, some in one.

    I am not familiar with the STATA codes. Can anybody help me or provide me with an example so I can adjust it accordingly to my data.I do not have extensive STATA programming knowledge. I am a beginner. Please use easy STATA language. My excuses. Thanks in advance.
    Last edited by Kim Vaarts; 19 May 2025, 18:28.

  • #2
    Please show some example data, as advised in the Statalist FAQ for new users, using the -dataex- command. It would also be quite helpful if you showed data examples of what you would like your new variables to be. (A "composite" could mean many things, so seeing actual examples of your desired composite variable would someone provide a way to get what you want.) Also, to give good advice about whether the long or wide format would be best, knowing what kinds of questions you want to answer with this data would also help.

    Comment


    • #3
      Kim Vaarts This is the third thread you've started in which you've been asked for a data example and been requested to study the FAQ Advice for detailed help on asking better questions.

      It's fine to be new to Stata: everyone starts that way. It's not fine to ignore advice intended in your own best interests.

      Comment


      • #4
        Nick Cox I understand. I want to delete this post and start en new one in accordance with the guidelines of this forum or else people moght respond. I will try to delete this post and if this is not possible, I will include the data example. I am writing this so everybody can read not to respond until I post the data example.

        Comment


        • #5
          Noted, but if you read the FAQ Advice as requested, you would already have found out that you cannot delete your own post.

          Comment


          • #6
            Nick Cox That is why I wrote that I will try to delete it and if I cannot do it (because I do not see the option) I wrote the prior message so that nobody responds to my question without a data example.

            Comment

            Working...
            X