turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- creating new variables by collapsing over repeated...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-18-2016 06:44 PM - edited 10-18-2016 07:04 PM

Hi! I am pretty new to coding in SAS, so please let me know if you need more info to answer my question. I'm using SAS Studio University Edition.

I have a data set (BBMP) with 3 independent variables (PRED, MANIP, and SP), a TRT column that identifies observations by PRED_MANIP_SP combination, and a binomial response (PACT) at each of 12 observation times (TIME) (See attached spreadsheet)

What I want to do is collapse over TIME so that I can create a variable for the number of of positive responses (1) for each TRT (new variable = Y) and a total N for each TRT that tallies TIME (new variable = N; subset here has N=12 for each REP and N=24 for each TRT), such that I can eventually create a proportion Y/N. How would I program a data step in SAS to create Y and N for me rather than manually creating a new spreadsheet with these variables?

Sample data:

REP | PRED | MANIP | SP | TRT | TIME | PACT |

HuMPAnN1 | An | N | Hu | HuMPAnN | 1 | 0 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 2 | 1 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 3 | 0 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 4 | 0 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 5 | 0 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 6 | 0 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 7 | 0 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 8 | 0 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 9 | 0 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 10 | 1 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 11 | 0 |

HuMPAnN1 | An | N | Hu | HuMPAnN | 12 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 1 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 2 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 3 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 4 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 5 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 6 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 7 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 8 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 9 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 10 | 1 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 11 | 0 |

HuMPAnN2 | An | N | Hu | HuMPAnN | 12 | 0 |

BgMPAG1 | A | G | Bg | BgMPAG | 2 | 0 |

BgMPAG1 | A | G | Bg | BgMPAG | 3 | 1 |

BgMPAG1 | A | G | Bg | BgMPAG | 4 | 0 |

BgMPAG1 | A | G | Bg | BgMPAG | 5 | 1 |

BgMPAG1 | A | G | Bg | BgMPAG | 6 | 0 |

BgMPAG1 | A | G | Bg | BgMPAG | 7 | 0 |

BgMPAG1 | A | G | Bg | BgMPAG | 8 | 1 |

BgMPAG1 | A | G | Bg | BgMPAG | 9 | 0 |

BgMPAG1 | A | G | Bg | BgMPAG | 10 | 0 |

BgMPAG1 | A | G | Bg | BgMPAG | 11 | 0 |

BgMPAG1 | A | G | Bg | BgMPAG | 12 | 1 |

BgMPAG2 | A | G | Bg | BgMPAG | 1 | 1 |

BgMPAG2 | A | G | Bg | BgMPAG | 2 | 0 |

BgMPAG2 | A | G | Bg | BgMPAG | 3 | 1 |

BgMPAG2 | A | G | Bg | BgMPAG | 4 | 0 |

BgMPAG2 | A | G | Bg | BgMPAG | 5 | 0 |

BgMPAG2 | A | G | Bg | BgMPAG | 6 | 1 |

BgMPAG2 | A | G | Bg | BgMPAG | 7 | 0 |

BgMPAG2 | A | G | Bg | BgMPAG | 8 | 0 |

BgMPAG2 | A | G | Bg | BgMPAG | 9 | 0 |

BgMPAG2 | A | G | Bg | BgMPAG | 10 | 0 |

BgMPAG2 | A | G | Bg | BgMPAG | 11 | 0 |

BgMPAG2 | A | G | Bg | BgMPAG | 12 | 0 |

Thanks in advance!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-18-2016 06:51 PM

Your sample data didn't come through to the forum.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

10-18-2016 06:53 PM

I attached a file.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-18-2016 06:56 PM

Generally, users won't download an XLSX file, you'll get a faster response if you post a small sample of data in your post.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

10-18-2016 06:59 PM

Fixed it, thanks!