Announcement

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

  • xpose question

    Hello,

    I am trying to use the labels from a column (assetype) as variable names when transposed to rows. My data look like this

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long sernum byte assetype double howmuch
     24071 2  2000
     34231 2  1684
     44061 4  6057
     44061 1   915
     44061 2   825
     44081 4 10000
     44081 2   500
     44111 9     5
     44111 1  3400
     54021 4   264
     54021 2  5600
     54021 1    20
     54031 1  1700
     54071 1   420
     54071 2  3100
     54161 2  2000
     54191 2  2500
     54191 9     4
     64151 2  5149
     74021 1   456
     74021 4  2309
     74021 9   124
     74021 2   940
     74021 8    20
     74151 2  5000
     74151 1    10
     74181 9     2
     74181 2  2278
     74201 2  2600
     84011 2  2111
     84011 1  2641
     84021 2  2900
     84021 4   150
     84021 1   100
     84041 2  1002
     84041 1   550
     84041 9    60
     84041 4  5000
     84111 1   280
     84111 2  5880
     84141 2  1803
     84141 1    10
     84161 2  2425
     84161 4  6974
     84161 9    10
     84161 1   949
     84221 1   350
     84221 4 10517
     84221 2  1100
     84241 1    80
     84241 2   100
     84241 9     1
     84241 4  2310
     94061 1   400
     94061 4  5000
     94061 2     4
     94151 2  1000
     94161 2  1180
     94161 1    50
    104021 1    10
    104021 2   100
    104041 2     3
    114011 2  4000
    114221 9     0
    114221 2  2500
    114221 1    10
    124081 9     1
    124081 4     0
    124081 1  2854
    124143 1   500
    124143 2  2000
    124143 9     2
    124151 9    40
    124151 2  2561
    124151 4  2800
    134191 2  2000
    154061 1   558
    154061 2  3600
    154131 2 10326
    154131 1  2700
    154131 8   264
    154131 4  2478
    154161 4  7400
    154161 2  3650
    154231 2  1050
    154231 1  1050
    164051 2  2700
    164061 1   200
    164061 2  1500
    164111 2  3000
    164111 4  2736
    164111 1  2100
    164191 2  1417
    164191 1    25
    164191 9    40
    164211 2     0
    164211 4  2500
    164251 2 10000
    164261 1  1000
    164261 2  3000
    end
    label values assetype assetype
    label def assetype 1 "current account", modify
    label def assetype 2 "savings account", modify
    label def assetype 4 "adult gilts/trusts/stocks/shares", modify
    label def assetype 8 "saye", modify
    label def assetype 9 "adult premium bonds", modify

    I tried using xpose and reshape but it did not work - I may be doing something wrong. Essentially, I need to transform the "assetype" and "howmuch" variables to something similar as the last few columns in the table below:


    Click image for larger version

Name:	1.JPG
Views:	1
Size:	36.6 KB
ID:	1664042


    I would appreciate if anyone could help me with this.

  • #2
    I think we may be missing some information because your data example seems to already have the structure you wanted.

    Comment


    • #3
      I agree that this isn't a problem for reshape or xpose.


      Code:
      separate howmuch, by(assetype) veryshortlabel
      seems to be what you are asking for, plus some cosmetic changes. Whether that's a really a good structure for analysis depends on ... the analysis.

      Comment


      • #4
        Thank you very much!

        Comment

        Working...
        X