Announcement

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

  • Twoway Graphs

    Dear all

    I have this panel data and would like to draw Twoway graphs to summarise variables.

    I have enormous data. This is just the first 100 obs
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long(Lockdown industry1) byte quarter
    . 6 3
    . 6 4
    . 6 5
    . 6 6
    . 6 7
    . 6 4
    . 6 5
    . 6 6
    . 6 7
    . 6 8
    . 6 4
    . 6 5
    . 6 6
    . 6 7
    . 6 8
    . 6 2
    . 6 3
    . 6 4
    . 6 5
    . 6 6
    . 19 3
    . 19 4
    . 19 5
    . 19 6
    . 19 7
    . 1 4
    . 1 5
    . 1 6
    136 1 7
    . 1 8
    . 1 4
    . 1 5
    . 1 6
    136 1 7
    . 1 8
    . 7 3
    . 7 4
    . 7 5
    . 7 6
    . 6 7
    . 19 3
    . 19 4
    . 19 5
    . 19 6
    . 19 7
    . 7 1
    . 7 2
    . 7 3
    . 7 4
    . 7 5
    . 6 3
    . 6 4
    . 6 5
    . 6 6
    . 6 7
    . 19 4
    . 6 5
    . 6 6
    . 6 7
    . 6 8
    . 12 4
    . 12 5
    95 12 6
    . 12 7
    123 12 8
    . 6 1
    . 6 2
    . 6 3
    . 6 4
    . 6 5
    . 23 2
    . 23 3
    . 23 4
    . 23 5
    96 23 6
    . 19 4
    . 19 5
    . 19 6
    . 19 7
    . 19 8
    . 6 4
    . 6 5
    . 6 6
    . 6 7
    . 6 8
    . 7 1
    . 7 2
    . 7 3
    . 7 4
    . 7 5
    . 23 1
    . 23 2
    . 23 3
    . 23 4
    . 23 5
    . 17 1
    . 17 2
    . 17 3
    . 17 4
    . 17 5
    end
    label values Lockdown Lockdown
    label def Lockdown 95 "4.1%", modify
    label def Lockdown 96 "4.4%", modify
    label def Lockdown 123 "6.3%", modify
    label def Lockdown 136 "7.6%", modify
    label values industry1 industry1
    label def industry1 1 "Accommodation And Food Service Activities", modify
    label def industry1 6 "Does not apply", modify
    label def industry1 7 "Education", modify
    label def industry1 12 "Human Health And Social Work Activities", modify
    label def industry1 17 "Other service activities", modify
    label def industry1 19 "Public admin and defence", modify
    label def industry1 23 "Wholesale And Retail Trade; Repair Of Motor Vehicles And Motorcycles", modify
    label values quarter quarter
    label def quarter 1 "Jan-Mar 2019", modify
    label def quarter 2 "April-June 2019", modify
    label def quarter 3 "July-Sep 2019", modify
    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

    The data has variables of time (quarter ), industry and lockdown of this industry by %.

    First Q: How can I use the option towaway graph to get the percentage of lockdowns in each industry over the whole period (quarters)?

    Based on my data, can I produce a graph showing the time series % of lockdowns in each industry over quarters in one graph?


    Could you help with that?






  • #2
    Your Lockdown variable is not fit for purpose. It has been encoded inappropriately Here is how to fix it.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long(Lockdown industry1) byte quarter
    136  1 7
    136  1 7
     95 12 6
    123 12 8
     96 23 6
    end
    label values Lockdown Lockdown
    label def Lockdown 95 "4.1%", modify
    label def Lockdown 96 "4.4%", modify
    label def Lockdown 123 "6.3%", modify
    label def Lockdown 136 "7.6%", modify
    
    * you start here 
    decode Lockdown, gen(work)
    drop Lockdown 
    label drop Lockdown 
    destring work, ignore(%) gen(Lockdown)
    
    
    list
    
         +--------------------------------------+
         | indust~1   quarter   work   Lockdown |
         |--------------------------------------|
      1. |        1         7   7.6%        7.6 |
      2. |        1         7   7.6%        7.6 |
      3. |       12         6   4.1%        4.1 |
      4. |       12         8   6.3%        6.3 |
      5. |       23         6   4.4%        4.4 |
         +--------------------------------------+

    Comment


    • #3
      Originally posted by Nick Cox View Post
      Your Lockdown variable is not fit for purpose. It has been encoded inappropriately Here is how to fix it.

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input long(Lockdown industry1) byte quarter
      136 1 7
      136 1 7
      95 12 6
      123 12 8
      96 23 6
      end
      label values Lockdown Lockdown
      label def Lockdown 95 "4.1%", modify
      label def Lockdown 96 "4.4%", modify
      label def Lockdown 123 "6.3%", modify
      label def Lockdown 136 "7.6%", modify
      
      * you start here
      decode Lockdown, gen(work)
      drop Lockdown
      label drop Lockdown
      destring work, ignore(%) gen(Lockdown)
      
      
      list
      
      +--------------------------------------+
      | indust~1 quarter work Lockdown |
      |--------------------------------------|
      1. | 1 7 7.6% 7.6 |
      2. | 1 7 7.6% 7.6 |
      3. | 12 6 4.1% 4.1 |
      4. | 12 8 6.3% 6.3 |
      5. | 23 6 4.4% 4.4 |
      +--------------------------------------+
      Many thanks for your reply

      I tried this command
      Code:
      twoway (scatter Lockdown industry1) (scatter Lockdown quarter)
      But it doesn't give me any sense. Could you suggest which best way for that?

      Comment


      • #4
        You are superimposing quite different graphs there. Your data example remains puzzling because there are so many missing values for Lockdown, Perhaps something like


        Code:
        scatter Lockdown quarter, by(industry)
        would make more sense.

        Comment

        Working...
        X