Announcement

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

  • Managing and spilt the datasets

    Dear all,

    I am dealing with a quarterly panel dataset – from Oct 2019 to Des 2020 – for workers, and I want to study the effect of a covid_19 closure in labour market. So I have five quarters in my datasets: Oct to Des 2019, the first quarter (the only quarter before closure in the labour market as well), and the other four quarters, all of them the period after closure. My question is: How can I separate my dataset to be pre and post period based on quarter and variable FLEXW7?

    I would like to get the untreated group ( Oct to Des 2019 ) and the treated group ( Jan to Des 2020) based on people working in Zero hours contracts ( FLEXW7)

    NOTE :
    FLEXW7 is a group of workers which takes on value "1" if working zero hours contracts labelled "Yes" and "2" if not working zero hours contracts labelled "No" also the variable has missing value (.)

    Here is the sample of data :
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double PERSID byte(quarter SEX Inde07m FLEXW7)
    10493040101 4 2 99 .
    10493040101 5 2 99 .
    10493040101 6 2 99 .
    10493040101 7 2 99 .
    10694020101 4 2 99 .
    10694020101 5 2 99 .
    10694020101 6 2 99 .
    10694020101 7 2 99 .
    10694020101 8 2 99 .
    10694020102 4 1 99 .
    10694020102 5 1 99 .
    10694020102 6 1 99 .
    10694020102 7 1 99 .
    10694020102 8 1 99 .
    10792030101 5 2 99 .
    10792030101 6 2 99 .
    10793010101 4 2 8 2
    10793010101 5 2 8 2
    10793010101 6 2 8 2
    10793010101 7 2 8 2
    10794010101 4 1 5 2
    10794010101 5 1 5 2
    10794010101 6 1 5 2
    10794010101 7 1 5 2
    10794010101 8 1 5 2
    10794010102 4 2 5 2
    10794010102 5 2 5 2
    10794010102 6 2 5 2
    10794010102 7 2 5 2
    10794010102 8 2 5 2
    10993020101 4 2 8 2
    10993020101 5 2 8 .
    10993020101 6 2 8 2
    10993020101 7 2 99 .
    10993020102 4 1 8 2
    10993020102 5 1 8 2
    10993020102 6 1 8 2
    10993020102 7 1 8 2
    11091010101 4 2 8 2
    11091010101 5 2 8 2
    11093030101 4 2 99 .
    11093030101 5 2 99 .
    11093030101 6 2 99 .
    11093030101 7 2 99 .
    11094010101 4 1 8 2
    11094010101 5 1 99 .
    11094010101 6 1 99 .
    11094010101 7 1 99 .
    11094010101 8 1 99 .
    11094010102 4 2 8 2
    11094010102 5 2 8 2
    11094010102 6 2 8 2
    11094010102 7 2 8 2
    11094010102 8 2 8 2
    11291020101 4 2 99 .
    11291020101 5 2 99 .
    11292020101 5 1 5 2
    11292020101 6 1 5 2
    11294030101 4 2 8 2
    11294030101 5 2 8 2
    11294030101 6 2 8 2
    11294030101 7 2 8 2
    11294030101 8 2 8 2
    11294030102 4 1 99 .
    11294030102 5 1 99 .
    11294030102 6 1 99 .
    11294030102 7 1 99 .
    11294030102 8 1 99 .
    20191020101 4 1 8 2
    20191020101 5 1 8 2
    20191020102 4 1 5 2
    20191020102 5 1 5 2
    20191040101 4 2 9 2
    20191040101 5 2 9 2
    20193010102 4 2 99 .
    20193010102 5 2 99 .
    20193010102 6 2 99 .
    20193010102 7 2 99 .
    20293010101 4 2 99 .
    20293010101 5 2 99 .
    20293010101 6 2 99 .
    20293010101 7 2 99 .
    20294040101 4 2 5 2
    20294040101 5 2 5 2
    20294040101 6 2 5 2
    20294040101 7 2 5 2
    20294040101 8 2 5 2
    20493010101 4 2 99 .
    20493010101 5 2 99 .
    20493010101 6 2 99 .
    20493010101 7 2 99 .
    20494030101 4 2 5 2
    20494030101 5 2 5 2
    20494030101 6 2 5 2
    20494030101 7 2 5 2
    20494030101 8 2 5 2
    20494030102 4 1 8 2
    20494030102 5 1 8 2
    20494030102 6 1 8 2
    20494030102 7 1 8 2
    end
    label values quarter quarter
    label def quarter 4 "Oct-Des 2019", modify
    label def quarter 5 "Jan-Mar 2020", modify
    label def quarter 6 "April-June 2020", modify
    label def quarter 7 "July-Sep 2020", modify
    label def quarter 8 "Oct-Des 2020", modify
    label values SEX SEX
    label def SEX 1 "Male", modify
    label def SEX 2 "Female", modify
    label values Inde07m Inde07m5
    label def Inde07m5 5 "G,I -Distribution, hotels and restaurants", modify
    label def Inde07m5 8 "O,P,Q - Public admin, education and health", modify
    label def Inde07m5 9 "R,S,T,U - Other services", modify
    label values FLEXW7 FLEXW75
    label def FLEXW75 2 "No", modify


    I tried to create a dummy variable
    Code:
    gen byte ZHC_post = FLEXW7 == 1 & quarter>=5
    gen byte ZHC_pre = FLEXW7 == 1 & quarter==4
    However, that did not work when I needed to produce a Histogram graph to compare people working in zero-hours contracts pre and post period.

    I appreciate getting any suggestions to solve this.
    [/QUOTE]


  • #2
    There is no point in generating two variables, ZHC_post and ZHC_pre that are simply negations of each other. A single variable that distinguishes the pre and post eras is all you need:

    Code:
    label define pre_post 0 "Before"    1   "After"
    gen byte ZHC_pre_post:pre_post = quarter > 4 if !missing(quarter)
    However, that did not work when I needed to produce a Histogram graph to compare people working in zero-hours contracts pre and post period.
    Saying that something "did not work" is not helpful. There are so many ways that a command can "not work." To get useful advice you need to say exactly what command(s) you gave, and exactly what happened (e.g. show any messages and results that Stata gave you, or say "Stata crashed" or "Stata hung", etc.). Then, unless it is blatantly obvious why the results are not what you wanted, explain how they differ. In your instance, it isn't even clear what kind of graph you were looking for. Histograms, at least in Stata, cannot be simply used to contrast two groups because the -histogram- command only graphs one group at a time. So for more helpful advice, please post back showing what you did and how Stata responded, and explain what you are actually trying to do.

    Comment

    Working...
    X