Announcement

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

  • Randomly generated data with parameters

    Hi There,

    In brief, I'm looking to create a sample/ example dataset conforming to a predefined construct whilst I wait for my fieldwork (primary data collection) to complete, which will enable us to start programming of analysis.

    By design, I know what data fields will be included in the final dataset, and the possible list of values reach data field can take, for example, age can range from 18-90, sex is M, F or U etc. Therefore, is it possible to draw random values from pre-specified lists (look-ups) to populate data fields, e.g. having a random distribution of M, F and U values within the data field representing sex?

    Taking it a step further, could the distribution be more weighted to selecting certain values that are known/ expected to occur more frequently, e.g. more M and F values for sex compared with U?

    In theory, it all 'feels' very do-able in Stats, but unsure where to start.

    Any help or insights would be greatly appreciated.

    Thanks,

    Rob.

  • #2
    Code:
    set obs 100
    gen age = round((90-18+1)*runiform() + 18)
    gen sex = ""
    replace sex = "M" in 1/40
    replace sex = "F" in 41/80
    replace sex = "U" in 81/100
    gen income = round((100000-10000+1)*runiform() + 10000)

    Comment

    Working...
    X