Announcement

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

  • Help for analysing Dataset

    Hi there,

    I have a dataset of 200'000 observations consisting of customer IDs for 14 years. I have 8 binary variables that represent a group that customers are a part of. Now I would like to know for each of the 14 years seperately how many customers belong to any of the 8 groups. So for example in year one 80% are group 1, 5% group two and so on. I hope there is a way so that I don't have to do each year by itself but all in one go.

    Any help is greatly appreciated.

    Kind regards

  • #2
    You have posted similar posts on three occasions, the last yesterday. In each case you got a reply from a experienced member, with the flavour that you need to give more information to get a better reply. In each case you just ignored the reply, which is not encouraging to those who tried to help you help yourself. Salutations like "Kind regards" don't erase the impression of mistreating the forum.

    This is the fourth such response. Clearly you cannot post the data here but you could post an example.

    Here is an example that may help. I made up a toy dataset in which each ID occurs at most once in each year and just one of 4 binary variables is 1 for that ID in that year.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(id year x1 x2 x3 x4)
    1 2018 1 0 0 0
    2 2018 0 1 0 0
    3 2018 0 0 1 0
    4 2019 0 0 0 1
    5 2019 0 0 1 0
    6 2019 0 1 0 0
    end
    
    
    gen which = x1
    forval j = 2/4 {
        replace which = `j' if x`j' == 1
    }
    contract which year
    tab year which
    
    
               |                    which
          year |         1          2          3          4 |     Total
    -----------+--------------------------------------------+----------
          2018 |         1          1          1          0 |         3
          2019 |         0          1          1          1 |         3
    -----------+--------------------------------------------+----------
         Total |         1          2          2          1 |         6
    If you can't adapt that to your problem then my only other advice is read the entirety of https://www.statalist.org/forums/help (including the advice on titles of threads and what to do if your data are confidential).

    Otherwise you're just wasting your time too with questions that people can't or won't answer.
    Last edited by Nick Cox; 18 Apr 2019, 04:52.

    Comment


    • #3
      I am sorry for any inconveniance I created and will ask any further questions in compliance to the forum rules as best as I can.

      Sorry Mr Cox and thank you for the work that you do.

      Comment

      Working...
      X