I have one question related to counting distinct values by groups. Here is an example of the data with ID, year, and the job code (i.e., job_code). What I am looking for is to create a variable (or collapse data) that shows how many jobs they have throughout the year from 1994 to 1996. For example, ID 1 had 3 jobs, ID 2 had 1 and ID 3 had 3.
Code:
input ID year job_code 1 1994 50 1 1995 53 1 1996 60 2 1994 35 3 1994 68 3 1995 60 3 1996 53 end
Code:
bysort ID: distinct job_code
Could anyone help me with this question, please? Thank you in advance, and stay safe.
0 Response to Count distinct values by groups
Post a Comment