creating new variables by collapsing over repeated measures

Reply
New Contributor Ma2
New Contributor
Posts: 3

creating new variables by collapsing over repeated measures

[ Edited ]

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:

REPPREDMANIPSPTRTTIMEPACT
HuMPAnN1AnNHuHuMPAnN10
HuMPAnN1AnNHuHuMPAnN21
HuMPAnN1AnNHuHuMPAnN30
HuMPAnN1AnNHuHuMPAnN40
HuMPAnN1AnNHuHuMPAnN50
HuMPAnN1AnNHuHuMPAnN60
HuMPAnN1AnNHuHuMPAnN70
HuMPAnN1AnNHuHuMPAnN80
HuMPAnN1AnNHuHuMPAnN90
HuMPAnN1AnNHuHuMPAnN101
HuMPAnN1AnNHuHuMPAnN110
HuMPAnN1AnNHuHuMPAnN120
HuMPAnN2AnNHuHuMPAnN10
HuMPAnN2AnNHuHuMPAnN20
HuMPAnN2AnNHuHuMPAnN30
HuMPAnN2AnNHuHuMPAnN40
HuMPAnN2AnNHuHuMPAnN50
HuMPAnN2AnNHuHuMPAnN60
HuMPAnN2AnNHuHuMPAnN70
HuMPAnN2AnNHuHuMPAnN80
HuMPAnN2AnNHuHuMPAnN90
HuMPAnN2AnNHuHuMPAnN101
HuMPAnN2AnNHuHuMPAnN110
HuMPAnN2AnNHuHuMPAnN120
BgMPAG1AGBgBgMPAG20
BgMPAG1AGBgBgMPAG31
BgMPAG1AGBgBgMPAG40
BgMPAG1AGBgBgMPAG51
BgMPAG1AGBgBgMPAG60
BgMPAG1AGBgBgMPAG70
BgMPAG1AGBgBgMPAG81
BgMPAG1AGBgBgMPAG90
BgMPAG1AGBgBgMPAG100
BgMPAG1AGBgBgMPAG110
BgMPAG1AGBgBgMPAG121
BgMPAG2AGBgBgMPAG11
BgMPAG2AGBgBgMPAG20
BgMPAG2AGBgBgMPAG31
BgMPAG2AGBgBgMPAG40
BgMPAG2AGBgBgMPAG50
BgMPAG2AGBgBgMPAG61
BgMPAG2AGBgBgMPAG70
BgMPAG2AGBgBgMPAG80
BgMPAG2AGBgBgMPAG90
BgMPAG2AGBgBgMPAG100
BgMPAG2AGBgBgMPAG110
BgMPAG2AGBgBgMPAG120

 


 

Thanks in advance!

Super User
Posts: 17,963

Re: creating new variables by collapsing over repeated measures

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

New Contributor Ma2
New Contributor
Posts: 3

Re: creating new variables by collapsing over repeated measures

I attached a file.

Super User
Posts: 17,963

Re: creating new variables by collapsing over repeated measures

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.

New Contributor Ma2
New Contributor
Posts: 3

Re: creating new variables by collapsing over repeated measures

Fixed it, thanks!

Ask a Question
Discussion stats
  • 4 replies
  • 363 views
  • 0 likes
  • 2 in conversation