+ Reply to Thread
Results 1 to 6 of 6

Thread: Re-arranging SAS data

  1. #1
    Points: 945, Level: 16
    Level completed: 45%, Points required for next Level: 55

    Posts
    21
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re-arranging SAS data



    I have data in this format:
    Admit Gender Department Count
    Admitted Male A 512
    Rejected Male A 313
    Admitted Female A 89
    Rejected Female A 19
    Admitted Male B 353
    Rejected Male B 207
    Admitted Female B 17
    Rejected Female B 8
    Admitted Male C 120

    And, I want to re-arrange it in a single data step loop (Suggested tools: MOD function, _N_ automatic variable, DROP statement, OUTPUT statement, and SELECT-WHEN construct) such that it looks like this:

    Department, Males Admitted, Males Rejected, Females Admitted, Females Rejected.

    A 512 313 89 19
    B 353 207 17 8
    C 120 205 202 391
    D 138 279 131 244
    E 53 138 94 299
    F 22 351 24 317


    Could someone please help me with the problem. I am lost ....

  2. #2
    Bhoot
    Points: 1,264, Level: 19
    Level completed: 64%, Points required for next Level: 36

    Posts
    1,758
    Thanks
    40
    Thanked 124 Times in 106 Posts

    Re: Re-arranging SAS data

    Use proc transpose. Here is one example
    In the long run, we're all dead.

  3. #3
    Points: 945, Level: 16
    Level completed: 45%, Points required for next Level: 55

    Posts
    21
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Re-arranging SAS data

    The link does not work ..

  4. #4
    Bhoot
    Points: 1,264, Level: 19
    Level completed: 64%, Points required for next Level: 36

    Posts
    1,758
    Thanks
    40
    Thanked 124 Times in 106 Posts

    Re: Re-arranging SAS data

    I updated it. In case it is not visible
    http://support.sas.com/documentation...a002473784.htm
    In the long run, we're all dead.

  5. #5
    Points: 945, Level: 16
    Level completed: 45%, Points required for next Level: 55

    Posts
    21
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Re-arranging SAS data

    I am required to do this using the DATA STEP approach and not via proc transpose.

  6. #6
    Bhoot
    Points: 1,264, Level: 19
    Level completed: 64%, Points required for next Level: 36

    Posts
    1,758
    Thanks
    40
    Thanked 124 Times in 106 Posts

    Re: Re-arranging SAS data


    Quote Originally Posted by sandeep249 View Post
    I am required to do this using the DATA STEP approach and not via proc transpose.
    That is not difficult in your case.
    Hint:
    Make four data sets using if and output ( like if admit= & gender = then output..). Rename the variable and join the datasets
    In the long run, we're all dead.

  7. The Following User Says Thank You to vinux For This Useful Post:

    sandeep249 (12-02-2012)

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats