Announcement

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

  • How to generate new variable from existing variables.

    Hello,
    I am new to STATA

    My exposure variable is sleep quality and I am planning to run logistic regression in STATA
    However, there are 4 items to measure sleep quality for each participants,each question has 6 scores
    (0) Not at all(1) 1-3 days(2) 4-7 days(3) 8-14 days(4) 15-21 day(5) 22-30 day


    Sleep quality items include:

    1. Have trouble falling asleep?

    2. Wake up several times per night but did not have trouble falling asleep again?

    3. Wake up one or more times per night (including waking far too early) and have trouble falling asleep again?

    4. Wake up after your usual amount of sleep feeling tired or worn out?



    - I have to exclude participants who didn't answer all questions and also to exclude participants who only answered 1 from these 4 items among the rest, those who experienced 15 or more days of any of the above 4 items classified as poor sleep quality the rest served as good sleep quality. So the cut off point is 15 days.

    I want to use all of them as 1 binary variable ( Good quality - Poor quality)

    Anyone can help me with the commands

    Looking forward for your replies

    Thank you

  • #2
    The necessary commands depend on the details of how your data are coded and arranged. Please show example data, using the -dataex- command to do so. If you are running version 15.1 or a fully updated version 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.



    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X