Announcement

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

  • Beginner: Generating a variable that counts frequency of multiple variables

    Hi all

    I have a task that requires me to generate a variable that will include a count of 4 different variables and their frequency.

    Currently what i have is: Variable: Data=Value,Frequency

    var30_0-1yearsofexperience: 0- 1, 1-2
    var30_2-3yearsofexperience 2-1, 3-0, 4-1
    var30_4-7yearsofexperience 5-3
    var30_8plusyearsofexperience - 6-0

    What i want is a new variable called e.g. Var30yearsofExperience that includes all of above.

    So I imagine it will look like this

    tab Var30yearsofExperience
    output:
    0-1
    1-2
    3-0,
    4-1
    5-3
    6-0

    0 to 6 is the value, or years of experience and 1-3 are the frequency.

    I cannot seem to find the command that will allow me to generate a new variable that includes the previous 4 frequency.

    I hope you can help.

    Bonus question:
    So the cutting line is actually 4 years. I think there is a mistake in the data as the employees with 4-years of experience are in category 2-3years, and should be counted in the next category for var30_4-7.
    Is there any way to transfer the counts/frequency of those who have 4 years of experience to another variable?
    Last edited by William Kalisa; 07 Apr 2022, 09:46. Reason: beginner, group, count, variables

  • #2
    Example:

    Current dataset:
    Variable Numeric Freq.
    var30_0-1yearsofexperience: 0- 1, 1-2 0 1
    var30_2-3yearsofexperience 2-1 2 1
    var30_4-7yearsofexperience 5 3
    var30_8plusyearsofexperience 6 0
    I am looking to generate a variable where all this information is displayed within the variable, so that when you tab it shows:
    Variable Numeric Freq.
    NEWVariable 0 1
    2 1
    5 3
    6 0

    Comment


    • #3
      Please provide a sample of your data using the dataex command. Load the dataset and type in

      Code:
      dataex in 1/20
      then copy the result and paste here.

      Comment

      Working...
      X