Announcement

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

  • transform data assign value

    Hi,
    I started with the software (v12). I would like to know if it is possible to transform the values as shown below

    my database is building with 107 columns and 1461 lines to represent date (tab1)
    a date is associated with 106 data

    I would like to reconstruct database to be
    a date, a value , 1 concentration (tab2)

    I tried to transform with long & wide format but the result does not match with what I want

    I will be grateful for any comments and suggestions


    date amb1 bou1 gram1 bou3 gram3 gram5
    01jan2012 . . .
    02jan2012 .
    03jan2012 .
    04jan2012 .
    05jan2012 .
    06jan2012 .

    tab2
    date taxon concentration
    01/01/12 bou1 .
    01/01/12 gram1 .
    01/01/12 bou3 .
    01/01/12 gram3 .
    01/01/12 gram5 .
    02/01/12 bou1 .
    02/01/12 gram1 .
    02/01/12 bou3 .
    02/01/12 gram3 .
    02/01/12 gram5 .
    03/01/12 bou1 .
    03/01/12 gram1 .
    03/01/12 bou3 .
    03/01/12 gram3 .
    03/01/12 gram5 .

  • #2
    You probably will want your post to be in the General forum and not the Mata forum.

    In the meantime, you could do something like the following.
    Code:
    foreach var of varlist _all {
        if "`var'" == "date" continue
        rename `var' concentration`var'
    }
    reshape long concentration, i(date) j(taxon) string
    If your taxon variables are all ambl#, bou# and gram# (or a similar limited list), then you can use the multiple reshape command to add the prefix and avoid the explicit loop. See the help file for reshape for details.

    Comment


    • #3
      great job ! thanks a lot for your help Joseph

      Comment

      Working...
      X