Announcement

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

  • Reshape long help

    Hi,

    I am trying to reshape long. Mci is a person's id. Right now I have data like month_id1 month_id2, prog_id1 prog_id2, but want this in a long format. When I try to reshape longI have done this:

    reshape long gender* race* emp_status* hh* ami* total* submitted_dt, i(ind* month_id* prog_id* prog_desc* psf* service_date*) j(day, string)

    But gives me error: "too many variables specified." Any ideas on fixing?
    Code:
    
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long mci_uniq_id byte(month_id1 month_id2) int(prog_id1 prog_id2)
    100017220 13 162   2
    1000 12 15 241   2
    105045 12 15 234 235
    107679 13  .   2   2
      11197 13  . 241 294
      107705 13  .  54  54
      126622 13  .   2  54
      16805 13  .   2   2
      108207  3  4   2   2
      11361031  3  4   .   .
    1606771  3  4   2   2
      123390  3  4   2   .
      11268050 23  2   2   2
    167602  2  9 234   2
    105339  2  9   .   .
    1072820  2  9   2 234
    17604  2  9  54 294
    1077491  2  9   .   .
    108 22 24   2   2
    1090338  6  6 294  54
    1017960  6  6 162 162
    1064716 11 24 241 241
      49688316 15  .   2   2
    10910 23  .   .   .
    10529 23  .   .   .
    100933 23  .   2   2
    107261  .  .   .   .
      4791 14 16   2   2
      59925  .  .   .   .
    19531 11 14   2   2
    10486 11 14   2   2
    10864418 11 14   2   2
      117415 11 14   2   2
    10766707  7  7   .   .
    10311353  7  7  54   2
      13009  7  7   2   2
    end

  • #2
    Try
    Code:
    reshape long gender* race* emp_status* hh* ami* total* submitted_dt, i(ind* month_id* prog_id* prog_desc* psf* service_date*) j(day) string

    Comment


    • #3
      Hmm still says too many variables!

      Comment


      • #4
        So, I fixed it using the following code. I think I misunderstood how to reshape long. So all the variables with numbers at the end are right after reshape long, then my ids, but I left out a few variables that were already long like gender, etc. So this worked!

        reshape long ind prog_id psf_field_name prog_desc service_date utility_amount rent_amount month_id, i(mci crrp_app_id) j(year)

        Comment

        Working...
        X