how can I transfer one colum data to a several-column data.

Discussion in 'SAS (Statistical Analysis Software)' started by norahlin, Sep 29, 2005.

  1. norahlin

    norahlin Guest

    the data would be like
    date category value
    1 1 100
    1 2 200
    2 1 210
    2 2 220


    How can I change it to

    date value of category1 value of category 2
    1 100 200
    2 210 220

    Thanks for help.
     
    norahlin, Sep 29, 2005
    #1
    1. Advertisements

  2. norahlin

    Toby Guest

    Norahlin ,

    data one ;
    infile cards ;
    input date category value ;
    cards ;
    1 1 100
    1 2 200
    2 1 210
    2 2 220
    ;
    run ;

    proc transpose
    data = one
    out = two (drop = _name_) prefix = Value_of_Category_;
    by date ;
    var value ;
    id category ;
    run ;

    proc print
    data = two ;
    run ;

    Toby Dunn


    the data would be like
    date category value
    1 1 100
    1 2 200
    2 1 210
    2 2 220


    How can I change it to


    date value of category1 value of category 2
    1 100 200
    2 210 220


    Thanks for help.
     
    Toby, Sep 29, 2005
    #2
    1. Advertisements

  3. norahlin

    norahlin Guest

    Thank you. It works.
     
    norahlin, Sep 29, 2005
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.